*
*/
+#if defined( __STDC__ ) // for standard C compiler
+#if __STDC_VERSION__ >= 199901L // for C99 and later
+#include <stdbool.h>
+#else // __STDC_VERSION__ >= 199901L
+#if !defined( bool )
+typedef enum {
+ false = 0,
+ true
+} bool;
+#endif // !defined( bool )
+#endif // __STDC_VERSION__ >= 199901L
+#else // defined( __STDC__ )
+#define bool int
+#define true 1
+#define false 0
+#endif // defined( __STDC__ )
+
#define MAX(a, b) ({ typeof(a) _a = a; typeof(b) _b = b; _a > _b? _a : _b; })
#define MIN(a, b) ({ typeof(a) _a = a; typeof(b) _b = b; _a < _b? _a : _b; })
*
*/
+#include "common.h"
+
typedef struct _cstack_t {
char *content;
size_t alloc;
int head;
void (*push)(struct _cstack_t *self, char c);
char (*pop)(struct _cstack_t *self);
- int (*top)(struct _cstack_t *self, char c);
- int (*empty)(struct _cstack_t *self);
+ bool (*top)(struct _cstack_t *self, char c);
+ bool (*empty)(struct _cstack_t *self);
void (*delete)(struct _cstack_t *self);
} cstack_t;
cstack_t *cstack_init();
void cstack_push(cstack_t *self, char c);
char cstack_pop(cstack_t *self);
-int cstack_top(cstack_t *self, char c);
-int cstack_empty(cstack_t *self);
+bool cstack_top(cstack_t *self, char c);
+bool cstack_empty(cstack_t *self);
void cstack_delete(cstack_t *self);
#endif // !defined( CSTACK_H )
deck_t *markdown_load(FILE *input);
int markdown_analyse(cstring_t *text);
void markdown_debug(deck_t *deck, int debug);
-int is_utf8(char ch);
+bool is_utf8(char ch);
int length_utf8(char ch);
int next_nonblank(cstring_t *text, int i);
int prev_blank(cstring_t *text, int i);
return self->content[self->head--];
}
-int cstack_top(cstack_t *self, char c) {
- if(self->head >= 0 && self->content[self->head] == c)
- return 1;
- return 0;
+bool cstack_top(cstack_t *self, char c) {
+ return self->head >= 0 && self->content[self->head] == c;
}
-int cstack_empty(cstack_t *self) {
+bool cstack_empty(cstack_t *self) {
return self->head == -1;
}
}
}
-int is_utf8(char ch) {
- return (ch & 0x80);
+bool is_utf8(char ch) {
+ return (ch & 0x80) != 0x00;
}
int length_utf8(char ch) {