This could read into the next line when a line was empty
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
#ifdef PAKFIRE_PRIVATE
int pakfire_string_endswith(const char* s, const char* suffix);
+char* pakfire_lstrip(const char* s);
#endif
#include <stdlib.h>
#include <pakfire/parser.h>
+#include <pakfire/util.h>
#include "grammar.h"
yy_push_state(NOKEYWORD);
}
-<READLINE>{whitespace} {
- // consume any leading whitespace
- }
-<READLINE>[^ \t].*$ {
+<READLINE>.*$ {
// Return to caller
yy_pop_state();
// Copy the entire string
- yylval.string = strdup(yytext);
+ yylval.string = pakfire_lstrip(yytext);
return T_STRING;
}
return !strcmp(s + strlen(s) - strlen(suffix), suffix);
}
+char* pakfire_lstrip(const char* s) {
+ while (*s && isspace(*s))
+ s++;
+
+ if (s)
+ return strdup(s);
+
+ return NULL;
+}
+
char* pakfire_format_size(double size) {
char string[STRING_SIZE];
const char* units[] = {" ", "k", "M", "G", "T", NULL};