Jspice3
quote.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Wayne A. Christopher
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * Various things for quoting words. If this is not ascii, quote and
10  * strip are no-ops, so '' and \ quoting won't work. To fix this, sell
11  * your IBM machine.
12  */
13 
14 #include "spice.h"
15 #include "cpdefs.h"
16 #include "suffix.h"
17 
18 
19 /* Strip all the 8th bits from a string (destructively). */
20 
21 void
23 
24 char *str;
25 {
26  if (str)
27  while (*str) {
28  *str = strip(*str);
29  str++;
30  }
31  return;
32 }
33 
34 
35 /* Quote all characters in a word. */
36 
37 void
39 
40 char *str;
41 {
42  if (str)
43  while (*str) {
44  *str = quote(*str);
45  str++;
46  }
47  return;
48 }
49 
50 
51 /* Print a word (strip the word first). */
52 
53 void
54 cp_printword(string, fp)
55 
56 char *string;
57 FILE *fp;
58 {
59  char *s;
60 
61  if (string)
62  for (s = string; *s; s++)
63  (void) putc((strip(*s)), fp);
64  return;
65 }
66 
67 
68 /* (Destructively) strip all the words in a wlist. */
69 
70 void
72 
73 wordlist *wlist;
74 {
75  wordlist *wl;
76 
77  for (wl = wlist; wl; wl = wl->wl_next)
78  cp_wstrip(wl->wl_word);
79  return;
80 }
81 
82 
83 /* Remove the "" from a string. */
84 
85 void
86 cp_unquote(string)
87 
88 char *string;
89 {
90  char *s;
91  int l;
92 
93  if (string == NULL) return;
94  s = string;
95  if (*s == '"')
96  while (*s) {
97  *(s) = *(s+1);
98  s++;
99  }
100  l = strlen(string) - 1;
101 
102  if (string[l] == '"')
103  string[l] = '\0';
104 
105  return;
106 }
void cp_wstrip(char *str)
Definition: quote.c:22
#define quote(c)
Definition: cpdefs.h:74
#define strip(c)
Definition: cpdefs.h:75
Definition: cddefs.h:119
Definition: library.c:18
Definition: cddefs.h:312
#define NULL
Definition: spdefs.h:121
Definition: cpstd.h:21
void cp_unquote(char *string)
Definition: quote.c:86
void cp_quoteword(char *str)
Definition: quote.c:38
struct wordlist * wl_next
Definition: cpstd.h:23
void cp_printword(char *string, FILE *fp)
Definition: quote.c:54
char * wl_word
Definition: cpstd.h:22
void cp_striplist(wordlist *wlist)
Definition: quote.c:71