coar 98/06/19 14:02:44
Modified: src CHANGES
src/ap Makefile.tmpl
src/include ap.h httpd.h
src/main util.c
Removed: src/ap ap_strings.c
Log:
Move ap_escape_quotes(), with its use of pools, out of libap.
Reviewed by: Dean Gaudet
Revision Changes Path
1.927 +4 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.926
retrieving revision 1.927
diff -u -r1.926 -r1.927
--- CHANGES 1998/06/19 13:31:28 1.926
+++ CHANGES 1998/06/19 21:02:30 1.927
@@ -1,5 +1,9 @@
Changes with Apache 1.3.1
+ *) Move ap_escape_quotes() from src/ap to src/main/util.c; it uses
+ pools and thus pollutes libap (until the pool stuff is moved there).
+ [Ken Coar]
+
*) IndexIgnore should be case-blind on Win32 (and any other case-aware
but case-insensitive platforms). [Ken Coar] PR#2455
1.24 +1 -4 apache-1.3/src/ap/Makefile.tmpl
Index: Makefile.tmpl
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/ap/Makefile.tmpl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Makefile.tmpl 1998/05/10 13:04:30 1.23
+++ Makefile.tmpl 1998/06/19 21:02:33 1.24
@@ -6,7 +6,7 @@
LIB=libap.a
OBJS=ap_execve.o ap_cpystrn.o ap_signal.o \
- ap_slack.o ap_snprintf.o ap_strings.o
+ ap_slack.o ap_snprintf.o
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $<
@@ -52,8 +52,5 @@
$(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
$(INCDIR)/util_uri.h $(INCDIR)/http_log.h
ap_snprintf.o: ap_snprintf.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
- $(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
- $(INCDIR)/util_uri.h
-ap_strings.o: ap_strings.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
$(OSDIR)/os.h $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
$(INCDIR)/util_uri.h
1.17 +0 -1 apache-1.3/src/include/ap.h
Index: ap.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/ap.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ap.h 1998/05/11 20:42:35 1.16
+++ ap.h 1998/06/19 21:02:36 1.17
@@ -67,7 +67,6 @@
API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t);
int ap_slack(int, int);
-API_EXPORT(char *) ap_escape_quotes(pool *, const char *);
API_EXPORT(int) ap_snprintf(char *, size_t, const char *, ...);
API_EXPORT(int) ap_vsnprintf(char *, size_t, const char *, va_list ap);
int ap_execle(const char *, const char *, ...);
1.225 +2 -0 apache-1.3/src/include/httpd.h
Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- httpd.h 1998/06/13 15:22:49 1.224
+++ httpd.h 1998/06/19 21:02:37 1.225
@@ -992,6 +992,8 @@
#define AP_SLACK_HIGH 2
#endif
+API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);
+
/*
* Redefine assert() to something more useful for an Apache...
*/
1.122 +50 -0 apache-1.3/src/main/util.c
Index: util.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/util.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- util.c 1998/06/13 15:22:54 1.121
+++ util.c 1998/06/19 21:02:42 1.122
@@ -1805,3 +1805,53 @@
*semi = ';';
}
}
+
+/*
+ * Given a string, replace any bare " with \" .
+ */
+API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring)
+{
+ int newlen = 0;
+ const char *inchr = instring;
+ char *outchr, *outstring;
+
+ /*
+ * Look through the input string, jogging the length of the output
+ * string up by an extra byte each time we find an unescaped ".
+ */
+ while (*inchr != '\0') {
+ newlen++;
+ if (*inchr == '"') {
+ newlen++;
+ }
+ /*
+ * If we find a slosh, and it's not the last byte in the string,
+ * it's escaping something - advance past both bytes.
+ */
+ if ((*inchr == '\\') && (inchr[1] != '\0')) {
+ inchr++;
+ }
+ inchr++;
+ }
+ outstring = ap_palloc(p, newlen + 1);
+ inchr = instring;
+ outchr = outstring;
+ /*
+ * Now copy the input string to the output string, inserting a slosh
+ * in front of every " that doesn't already have one.
+ */
+ while (*inchr != '\0') {
+ if ((*inchr == '\\') && (inchr[1] != '\0')) {
+ *outchr++ = *inchr++;
+ *outchr++ = *inchr++;
+ }
+ if (*inchr == '"') {
+ *outchr++ = '\\';
+ }
+ if (*inchr != '\0') {
+ *outchr++ = *inchr++;
+ }
+ }
+ *outchr = '\0';
+ return outstring;
+}