- if((s = strchr(s, '\n')) != NULL) {
- *s = '\0';
- }
-
- /* extract sec, kb, kps, orig-kb from 'rest', if present. This isn't the stone age
- * anymore, so we'll just do it the easy way (a regex) */
- bzero(®ex, sizeof(regex));
- reg_result = regcomp(®ex,
- "\\[sec ([0-9.]+) kb ([0-9]+) kps [0-9.]+ orig-kb ([0-9]+)\\]", REG_EXTENDED);
- if (reg_result != 0) {
- error("Error compiling regular expression for parsing log lines");
- /* NOTREACHED */
- }
-
- /* an error here just means the line wasn't found -- not fatal. */
- reg_result = regexec(®ex, rest, sizeof(pmatch)/sizeof(*pmatch), pmatch, 0);
- if (reg_result == 0) {
- char *str;
-
- str = find_regex_substring(rest, pmatch[1]);
- sec = atof(str);
- amfree(str);
-
- str = find_regex_substring(rest, pmatch[2]);
- kb = OFF_T_ATOI(str);
- amfree(str);
-
- str = find_regex_substring(rest, pmatch[3]);
- orig_kb = OFF_T_ATOI(str);
- amfree(str);
- } else {
- regfree(®ex);
- bzero(®ex, sizeof(regex));
- /* the .* at the end of this captures the old {wr: .. } statistics */
- reg_result = regcomp(®ex,
- "\\[sec ([0-9.]+) kb ([0-9]+) kps [0-9.]+.*\\]", REG_EXTENDED);
- if (reg_result != 0) {
- error("Error compiling regular expression for parsing log lines");
- /* NOTREACHED */
+ skip_non_whitespace(s, ch);
+ rest_undo = s - 1;
+ *rest_undo = '\0';
+ if (strcmp(rest, "[sec") == 0) {
+ skip_whitespace(s, ch);
+ if(ch == '\0') {
+ g_printf(_("strange log line in %s \"%s\"\n"),
+ logfile, curstr);
+ continue;
+ }
+ sec = atof(s - 1);
+ skip_non_whitespace(s, ch);
+ skip_whitespace(s, ch);
+ rest = s - 1;
+ skip_non_whitespace(s, ch);
+ rest_undo = s - 1;
+ *rest_undo = '\0';
+ if (strcmp(rest, "kb") != 0 &&
+ strcmp(rest, "bytes") != 0) {
+ g_printf(_("Bstrange log line in %s \"%s\"\n"),
+ logfile, curstr);
+ continue;