I am debugging a lot of scripts that I hadn't written myself and there are hundreds of functions so it would be impossible to copy everything and I am not sure even if copying this will help at all.
I suppose the best is to show one of the last parts of code that I see being executed before segmentation fault:
The main script calls the function as:
Code:
tokenise(line, tok, 10);
where line is the line number of the file that it is reading, and tok is gotten from:
Code:
strtok(line, "\n");
The function is defined as:
Code:
int tokenise(char *line, char **tok, int form_block) {
int co1, co2, co3, line_len, no_tok;
line_len = strlen(line + 1);
no_tok = blocks[form_block].no_field;
/* Copy tokens from line by column position */
for (co1 = 0; co1 < no_tok; ++co1) {
tok[co1] = line - 1 + blocks[form_block].field_start[co1];
if ((*(tok[co1] + blocks[form_block].field_width[co1]) != '\0') &&
(*(tok[co1] + blocks[form_block].field_width[co1]) != ' ') ) {
fprintf(stdout, "\nWarning: field-separator placed over non-space character '%c' (line %d, char %d, token %d) block %s",
*(tok[co1] + blocks[form_block].field_width[co1]), line_co,
blocks[form_block].field_start[co1] + blocks[form_block].field_width[co1], co1 + 1, blocks[form_block].name);
}
sprintf(tok[co1] + blocks[form_block].field_width[co1], "");
/* If token is empty, spaces or dng chars, set to DNG chars */
if (strspn(tok[co1], " -") == strlen(tok[co1])) {
for (co2 = 0; co2 < strlen(tok[co1]); ++co2) tok[co1][co2] = '-';
} else {
/*Strip leading and trailing spaces */
if (strlen(tok[co1]) > 0) {
tok[co1] += strspn(tok[co1], " ");
while (strcmp(tok[co1] + (strlen(tok[co1]) - 1), " ") == 0) strcpy(tok[co1] + (strlen(tok[co1]) - 1), "");
}
}
}
return EXIT_SUCCESS;
}