/* sudo_parseln() flags */
#define PARSELN_COMM_BOL 1 /* comments only at begining of line */
+#define PARSELN_CONT_IGN 2 /* ignore line continuation char */
/*
* Macros to quiet gcc's warn_unused_result attribute.
size_t linesize = 0, total = 0;
ssize_t len;
char *cp, *line = NULL;
- bool continued;
+ bool continued, comment;
debug_decl(sudo_parseln, SUDO_DEBUG_UTIL)
do {
+ comment = false;
continued = false;
len = getline(&line, &linesize, fp);
if (len == -1)
if (cp == line || !ISSET(flags, PARSELN_COMM_BOL)) {
*cp = '\0';
len = (ssize_t)(cp - line);
+ comment = true;
+ }
+ }
+ if (!comment && !ISSET(flags, PARSELN_CONT_IGN)) {
+ if (len > 0 && line[len - 1] == '\\' && (len == 1 || line[len - 2] != '\\')) {
+ line[--len] = '\0';
+ continued = true;
}
- } else if (len > 0 && line[len - 1] == '\\' && (len == 1 || line[len - 2] != '\\')) {
- line[--len] = '\0';
- continued = true;
}
/* Trim leading and trailing whitespace */