pinosaur
/
smdp.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for bool type.
[smdp.git]
/
src
/
parser.c
diff --git
a/src/parser.c
b/src/parser.c
index
7a54986
..
ce3f702
100644
(file)
--- a/
src/parser.c
+++ b/
src/parser.c
@@
-22,8
+22,10
@@
*/
#include <ctype.h>
*/
#include <ctype.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "parser.h"
#include "parser.h"
@@
-34,20
+36,21
@@
deck_t *markdown_load(FILE *input) {
int l = 0; // line length
int hc = 0; // header count
int lc = 0; // line count
int l = 0; // line length
int hc = 0; // header count
int lc = 0; // line count
- int sc =
0
; // slide count
+ int sc =
1
; // slide count
int bits = 0; // markdown bits
deck_t *deck = new_deck();
int bits = 0; // markdown bits
deck_t *deck = new_deck();
- slide_t *slide =
new_slide()
;
+ slide_t *slide =
deck->slide
;
line_t *line = NULL;
line_t *tmp = NULL;
cstring_t *text = cstring_init();
line_t *line = NULL;
line_t *tmp = NULL;
cstring_t *text = cstring_init();
- // assign first slide to deck
- deck->slide = slide;
- sc++;
-
while ((c = fgetc(input)) != EOF) {
while ((c = fgetc(input)) != EOF) {
+ if (ferror(input)) {
+ fprintf(stderr, "markdown_load() failed to read input: %s\n", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
if(c == '\n') {
// markdown analyse
if(c == '\n') {
// markdown analyse
@@
-178,8
+181,8
@@
deck_t *markdown_load(FILE *input) {
}
// split linked list
}
// split linked list
- line->prev->next =
(void*)0
;
- line->prev =
(void*)0
;
+ line->prev->next =
NULL
;
+ line->prev =
NULL
;
// remove header lines from slide
deck->slide->line = line;
// remove header lines from slide
deck->slide->line = line;
@@
-360,9
+363,6
@@
int markdown_analyse(cstring_t *text) {
if(text->text[i] == ' ') {
spaces++;
if(text->text[i] == ' ') {
spaces++;
- } else if(CHECK_BIT(bits, IS_CODE)) {
- other++;
-
} else {
switch(text->text[i]) {
case '=': equals++; break;
} else {
switch(text->text[i]) {
case '=': equals++; break;
@@
-478,8
+478,8
@@
void markdown_debug(deck_t *deck, int debug) {
}
}
}
}
-
int
is_utf8(char ch) {
- return (ch & 0x80);
+
bool
is_utf8(char ch) {
+ return (ch & 0x80)
!= 0x00
;
}
int length_utf8(char ch) {
}
int length_utf8(char ch) {