+/*
+ * Internal prototypes
+ */
+
+static int pcrs_parse_perl_options(const char *optstring, int *flags);
+static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int trivialflag,
+ int capturecount, int *errptr);
+
+/*********************************************************************
+ *
+ * Function : pcrs_strerror
+ *
+ * Description : Return a string describing a given error code.
+ *
+ * Parameters :
+ * 1 : error = the error code
+ *
+ * Returns : char * to the descriptive string
+ *
+ *********************************************************************/
+const char *pcrs_strerror(const int error)
+{
+ if (error < 0)
+ {
+ switch (error)
+ {
+ /* Passed-through PCRE error: */
+ case PCRE_ERROR_NOMEMORY: return "(pcre:) No memory";
+
+ /* Shouldn't happen unless PCRE or PCRS bug, or user messed with compiled job: */
+ case PCRE_ERROR_NULL: return "(pcre:) NULL code or subject or ovector";
+ case PCRE_ERROR_BADOPTION: return "(pcre:) Unrecognized option bit";
+ case PCRE_ERROR_BADMAGIC: return "(pcre:) Bad magic number in code";
+ case PCRE_ERROR_UNKNOWN_NODE: return "(pcre:) Bad node in pattern";
+
+ /* Can't happen / not passed: */
+ case PCRE_ERROR_NOSUBSTRING: return "(pcre:) Fire in power supply";
+ case PCRE_ERROR_NOMATCH: return "(pcre:) Water in power supply";
+
+ /* PCRS errors: */
+ case PCRS_ERR_NOMEM: return "(pcrs:) No memory";
+ case PCRS_ERR_CMDSYNTAX: return "(pcrs:) Syntax error while parsing command";
+ case PCRS_ERR_STUDY: return "(pcrs:) PCRE error while studying the pattern";
+ case PCRS_ERR_BADJOB: return "(pcrs:) Bad job - NULL job, pattern or substitute";
+ case PCRS_WARN_BADREF: return "(pcrs:) Backreference out of range";
+
+ /* What's that? */
+ default: return "Unknown error";
+ }
+ }
+ /* error >= 0: No error */
+ return "(pcrs:) Everything's just fine. Thanks for asking.";
+
+}
+