source: trunk/athena/bin/discuss/edsc/do_quote.c @ 22404

Revision 22404, 1.0 KB checked in by ghudson, 19 years ago (diff)
Eliminate declarations of system functions which cause warnings or errors. Fix some broken ss library calls.
Line 
1/*
2 *
3 *      Copyright (C) 1989 by the Massachusetts Institute of Technology
4 *      Developed by the MIT Student Information Processing Board (SIPB).
5 *      For copying information, see the file mit-copyright.h in this release.
6 *
7 */
8/*
9 *
10 * Created by: Mark W. Eichin <eichin@athena.mit.edu>
11 * $Id: do_quote.c,v 1.4 2006-03-10 07:11:37 ghudson Exp $
12 *
13 */
14#ifndef lint
15static char rcsid_do_quote_c[] = "$Id: do_quote.c,v 1.4 2006-03-10 07:11:37 ghudson Exp $";
16#endif /* lint */
17
18#include <stdlib.h>
19
20/*
21 *
22 * do_quote ()  -- requote a string so that Lisp won't barf on it.
23 *                 Basically requotes '"' and '\'.  Returns a malloc'd
24 *                 copy of the original string.
25 *
26 *                 Warning:  This routine frees its argument, so the
27 *                 canonical way of calling it is:  frep = do_quote(frep).
28 *
29 */
30
31char *do_quote(s)
32     char *s;
33{
34  char *ret, *t;
35
36  t = ret = malloc(2*strlen(s)+1);
37
38  while(*s) {
39    switch(*s) {
40    case '"':
41    case '\\':
42      *(t++) = '\\';
43    default:
44      *(t++) = *(s++);
45    }
46  }
47  *t = '\0';
48 
49  return(ret);
50}
51
52   
53
Note: See TracBrowser for help on using the repository browser.