-const char pcrs_rcs[] = "$Id: pcrs.c,v 1.6 2001/06/03 19:12:45 oes Exp $";
+const char pcrs_rcs[] = "$Id: pcrs.c,v 1.7 2001/06/29 13:33:04 oes Exp $";
/*********************************************************************
*
*
* Revisions :
* $Log: pcrs.c,v $
+ * Revision 1.7 2001/06/29 13:33:04 oes
+ * - Cleaned up, renamed and reordered functions,
+ * improved comments
+ * - Removed my_strsep
+ * - Replaced globalflag with a general flags int
+ * that holds PCRS_GLOBAL, PCRS_SUCCESS, and PCRS_TRIVIAL
+ * - Introduced trivial option that will prevent pcrs
+ * from honouring backreferences in the substitute,
+ * which is useful for large substitutes that are
+ * red in from somewhere and saves the pain of escaping
+ * the backrefs
+ * - Introduced convenience function pcrs_free_joblist()
+ * - Split pcrs_make_job() into pcrs_compile(), which still
+ * takes a complete s/// comand as argument and parses it,
+ * and a new function pcrs_make_job, which takes the
+ * three separate components. This should make for a
+ * much friendlier frontend.
+ * - Removed create_pcrs_job() which was useless
+ * - Fixed a bug in pcrs_execute
+ * - Success flag is now handled by pcrs instead of user
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.6 2001/06/03 19:12:45 oes
* added FIXME
*
case 's': rc |= PCRE_DOTALL; break;
case 'x': rc |= PCRE_EXTENDED; break;
case 'U': rc |= PCRE_UNGREEDY; break;
- case 'T': *flags |= PCRS_TRIVIAL; break;
+ case 'T': *flags |= PCRS_TRIVIAL; break;
default: break;
}
}
if (trivialflag)
{
- k = length;
+ k = length;
}
else
- {
+ {
for (i=0; i < length; i++)
{
/* Backslash treatment */
text[k++] = replacement[i];
quoted = 0;
}
- } /* -END- if (!trivialflag) */
+ } /* -END- if (!trivialflag) */
text[k] = '\0';
r->text = text;
*/
limit = strlen(command);
if (limit < 4)
- {
+ {
*errptr = PCRS_ERR_CMDSYNTAX;
return NULL;
}
else
- {
- delimiter = command[1];
- }
+ {
+ delimiter = command[1];
+ }
tokens[l] = (char *) malloc(limit + 1);
if (command[i] == delimiter && !quoted)
{
- if (l == 3)
- {
- l = -1;
+ if (l == 3)
+ {
+ l = -1;
break;
}
- tokens[0][k++] = '\0';
+ tokens[0][k++] = '\0';
tokens[++l] = tokens[0] + k;
- continue;
+ continue;
}
else if (command[i] == '\\' && !quoted && i+1 < limit && command[i+1] == delimiter)
*/
if (l != 3)
{
- *errptr = PCRS_ERR_CMDSYNTAX;
+ *errptr = PCRS_ERR_CMDSYNTAX;
free(tokens[0]);
return NULL;
}
- newjob = pcrs_make_job(tokens[1], tokens[2], tokens[3], errptr);
+ newjob = pcrs_make_job(tokens[1], tokens[2], tokens[3], errptr);
free(tokens[0]);
return newjob;
while ((submatches = pcre_exec(job->pattern, job->hints, subject, subject_length, offset, 0, offsets, 3 * PCRS_MAX_SUBMATCHES)) > 0)
{
- job->flags |= PCRS_SUCCESS;
+ job->flags |= PCRS_SUCCESS;
matches[i].submatches = submatches;
for (k=0; k < submatches; k++)
{