summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c125
1 files changed, 62 insertions, 63 deletions
diff --git a/src/util.c b/src/util.c
index cfa7fc0..a54288d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -22,94 +22,93 @@
#include "util.h"
int
-load_expr (struct tib_expr *dest, const char *src)
+load_expr(struct tib_expr *dest, const char *src)
{
- unsigned int len = strlen (src);
- for (unsigned int i = 0; i < len; ++i)
- {
- int rc = tib_expr_push (dest, src[i]);
- if (rc)
- return rc;
- }
+ unsigned int len = strlen(src);
+ for (unsigned int i = 0; i < len; ++i)
+ {
+ int rc = tib_expr_push(dest, src[i]);
+ if (rc)
+ return rc;
+ }
- return 0;
+ return 0;
}
int
-load_expr_num (struct tib_expr *dest, const char *src)
+load_expr_num(struct tib_expr *dest, const char *src)
{
- int rc = load_expr (dest, src);
- if (rc)
- return rc;
+ int rc = load_expr(dest, src);
+ if (rc)
+ return rc;
- int e = tib_expr_indexof_r (dest, 'e');
- if (e >= 0)
- {
- tib_expr_delete (dest, e);
+ int e = tib_expr_indexof_r(dest, 'e');
+ if (e >= 0)
+ {
+ tib_expr_delete(dest, e);
- if ('+' == dest->data[e])
- dest->data[e] = TIB_CHAR_EPOW10;
- else
- rc = tib_expr_insert (dest, e, TIB_CHAR_EPOW10);
- }
+ if ('+' == dest->data[e])
+ dest->data[e] = TIB_CHAR_EPOW10;
+ else
+ rc = tib_expr_insert(dest, e, TIB_CHAR_EPOW10);
+ }
- return rc;
+ return rc;
}
const char *
-display_special_char (int c)
+display_special_char(int c)
{
- static const int SKIPS[] =
- {
- TIB_CHAR_DEGREE,
- TIB_CHAR_EPOW10,
- TIB_CHAR_GREATEREQUAL,
- TIB_CHAR_L1,
- TIB_CHAR_L2,
- TIB_CHAR_L3,
- TIB_CHAR_L4,
- TIB_CHAR_L5,
- TIB_CHAR_L6,
- TIB_CHAR_L7,
- TIB_CHAR_L8,
- TIB_CHAR_L9,
- TIB_CHAR_LESSEQUAL,
- TIB_CHAR_PI,
- TIB_CHAR_SMALL1,
- TIB_CHAR_SMALL2,
- TIB_CHAR_SMALL3,
- TIB_CHAR_SMALL4,
- TIB_CHAR_SMALL5,
- TIB_CHAR_SMALL6,
- TIB_CHAR_SMALL7,
- TIB_CHAR_SMALL8,
- TIB_CHAR_SMALL9,
- TIB_CHAR_SMALL_MINUS,
- TIB_CHAR_STO,
- TIB_CHAR_THETA
- };
+ static const int SKIPS[] = {
+ TIB_CHAR_DEGREE,
+ TIB_CHAR_EPOW10,
+ TIB_CHAR_GREATEREQUAL,
+ TIB_CHAR_L1,
+ TIB_CHAR_L2,
+ TIB_CHAR_L3,
+ TIB_CHAR_L4,
+ TIB_CHAR_L5,
+ TIB_CHAR_L6,
+ TIB_CHAR_L7,
+ TIB_CHAR_L8,
+ TIB_CHAR_L9,
+ TIB_CHAR_LESSEQUAL,
+ TIB_CHAR_PI,
+ TIB_CHAR_SMALL1,
+ TIB_CHAR_SMALL2,
+ TIB_CHAR_SMALL3,
+ TIB_CHAR_SMALL4,
+ TIB_CHAR_SMALL5,
+ TIB_CHAR_SMALL6,
+ TIB_CHAR_SMALL7,
+ TIB_CHAR_SMALL8,
+ TIB_CHAR_SMALL9,
+ TIB_CHAR_SMALL_MINUS,
+ TIB_CHAR_STO,
+ TIB_CHAR_THETA
+ };
- for (unsigned int i = 0; i < (sizeof SKIPS / sizeof (int)); ++i)
- if (SKIPS[i] == c)
- return NULL;
+ for (unsigned int i = 0; i < (sizeof SKIPS / sizeof(int)); ++i)
+ if (SKIPS[i] == c)
+ return NULL;
- return tib_special_char_text (c);
+ return tib_special_char_text(c);
}
char *
-get_expr_display_str (const struct tib_expr *expr)
+get_expr_display_str(const struct tib_expr *expr)
{
- return tib_expr_tostr_f (expr, display_special_char);
+ return tib_expr_tostr_f(expr, display_special_char);
}
int
-max (int x, int y)
+max(int x, int y)
{
- return (x > y) ? x : y;
+ return (x > y) ? x : y;
}
int
-min (int x, int y)
+min(int x, int y)
{
- return (x < y) ? x : y;
+ return (x < y) ? x : y;
}