about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTParse.c
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation/HTParse.c')
-rw-r--r--WWW/Library/Implementation/HTParse.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index c7255995..b5112341 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -19,7 +19,7 @@ struct struct_parts {
 };
 
 
-/*	Strip white space off a string. 			HTStrip()
+/*	Strip white space off a string.				HTStrip()
 **	-------------------------------
 **
 ** On exit,
@@ -27,7 +27,7 @@ struct struct_parts {
 **	All trailing white space is OVERWRITTEN with zero.
 */
 PUBLIC char * HTStrip ARGS1(
-	char *, 	s)
+	char *,		s)
 {
 #define SPACE(c) ((c == ' ') || (c == '\t') || (c == '\n'))
     char * p = s;
@@ -55,7 +55,7 @@ PUBLIC char * HTStrip ARGS1(
 **	Any which are nonzero point to zero terminated strings.
 */
 PRIVATE void scan ARGS2(
-	char *, 		name,
+	char *,			name,
 	struct struct_parts *,	parts)
 {
     char * after_access;
@@ -178,7 +178,7 @@ PRIVATE void scan ARGS2(
 **	wanted		A mask for the bits which are wanted.
 **
 ** On exit,
-**	returns 	A pointer to a calloc'd string which MUST BE FREED
+**	returns		A pointer to a calloc'd string which MUST BE FREED
 */
 PUBLIC char * HTParse ARGS3(
 	CONST char *,	aName,
@@ -208,7 +208,7 @@ PUBLIC char * HTParse ARGS3(
     **	Allocate the output string.
     */
     len = strlen(aName) + strlen(relatedName) + 10;
-    result = (char *)calloc(1, len);	/* Lots of space: more than enough */
+    result = typecallocn(char, len);	/* Lots of space: more than enough */
     if (result == NULL) {
 	outofmem(__FILE__, "HTParse");
     }
@@ -484,7 +484,7 @@ PUBLIC char * HTParse ARGS3(
 **	or	../../albert.html
 */
 PUBLIC void HTSimplify ARGS1(
-	char *, 	filename)
+	char *,		filename)
 {
     char *p;
     char *q, *q1;
@@ -682,7 +682,7 @@ PUBLIC char * HTRelative ARGS2(
 	for (; *q && (*q != '#'); q++)
 	    if (*q == '/')
 		levels++;
-	result = (char *)calloc(1, (3*levels + strlen(last_slash) + 1));
+	result = typecallocn(char, 3*levels + strlen(last_slash) + 1);
 	if (result == NULL)
 	    outofmem(__FILE__, "HTRelative");
 	result[0] = '\0';
@@ -691,7 +691,7 @@ PUBLIC char * HTRelative ARGS2(
 	strcat(result, last_slash+1);
     }
     CTRACE((tfp,
-        "HTparse: `%s' expressed relative to\n   `%s' is\n   `%s'.\n",
+	"HTparse: `%s' expressed relative to\n	 `%s' is\n   `%s'.\n",
 		aName, relatedName, result));
     return result;
 }
@@ -709,7 +709,7 @@ PUBLIC char * HTRelative ARGS2(
 PRIVATE CONST unsigned char isAcceptable[96] =
 
 /*	Bit 0		xalpha		-- see HTFile.h
-**	Bit 1		xpalpha 	-- as xalpha but with plus.
+**	Bit 1		xpalpha		-- as xalpha but with plus.
 **	Bit 3 ...	path		-- as xpalphas but with /
 */
     /*	 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@@ -734,7 +734,7 @@ PUBLIC char * HTEscape ARGS2(
     for (p = str; *p; p++)
 	if (!ACCEPTABLE(UCH(TOASCII(*p))))
 	    unacceptable++;
-    result = (char *)calloc(1, (p-str + unacceptable + unacceptable + 1));
+    result = typecallocn(char, p-str + unacceptable + unacceptable + 1);
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
     for (q = result, p = str; *p; p++) {
@@ -772,7 +772,7 @@ PUBLIC char * HTEscapeSP ARGS2(
     for (p = str; *p; p++)
 	if (!(*p == ' ' || ACCEPTABLE(UCH(TOASCII(*p)))))
 	    unacceptable++;
-    result = (char *)calloc(1, (p-str + unacceptable + unacceptable + 1));
+    result = typecallocn(char, p-str + unacceptable + unacceptable + 1);
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
     for (q = result, p = str; *p; p++) {
@@ -808,7 +808,7 @@ PRIVATE char from_hex ARGS1(
 }
 
 PUBLIC char * HTUnEscape ARGS1(
-	char *, 	str)
+	char *,		str)
 {
     char * p = str;
     char * q = str;
@@ -856,7 +856,7 @@ PUBLIC char * HTUnEscape ARGS1(
 **	The first string is converted in place, as it will never grow.
 */
 PUBLIC char * HTUnEscapeSome ARGS2(
-	char *, 	str,
+	char *,		str,
 	CONST char *,	do_trans)
 {
     char * p = str;
@@ -889,7 +889,7 @@ PUBLIC char * HTUnEscapeSome ARGS2(
 PRIVATE CONST unsigned char crfc[96] =
 
 /*	Bit 0		xalpha		-- need "quoting"
-**	Bit 1		xpalpha 	-- need \escape if quoted
+**	Bit 1		xpalpha		-- need \escape if quoted
 */
     /*	 0 1 2 3 4 5 6 7 8 9 A B C D E F */
     {	 1,0,3,0,0,0,0,0,1,1,0,0,1,0,1,0,	/* 2x	!"#$%&'()*+,-./  */
@@ -930,7 +930,7 @@ PUBLIC void HTMake822Word ARGS1(
     }
     if (!added)
 	return;
-    result = (char *)calloc(1, (p-(*str) + added + 1));
+    result = typecallocn(char, p-(*str) + added + 1);
     if (result == NULL)
 	outofmem(__FILE__, "HTMake822Word");
     result[0] = '"';
cipes' href='/akkartik/mu/commit/cpp/016jump?h=hlt&id=1848b18f02b158861008214efd19708585bfcbe5'>1848b18f ^
201b2e6c ^

201b2e6c ^

dcfca05e ^
201b2e6c ^





dcfca05e ^
a767dbd3 ^

201b2e6c ^


88be3dbc ^
201b2e6c ^



6f5d7864 ^
201b2e6c ^

6f5d7864 ^
57699011 ^
201b2e6c ^
88be3dbc ^
201b2e6c ^



6f5d7864 ^
201b2e6c ^
6f5d7864 ^
57699011 ^
201b2e6c ^
1848b18f ^

201b2e6c ^

201b2e6c ^

dcfca05e ^
201b2e6c ^





dcfca05e ^
a767dbd3 ^

201b2e6c ^


88be3dbc ^
201b2e6c ^



6f5d7864 ^
201b2e6c ^

6f5d7864 ^
57699011 ^
201b2e6c ^
88be3dbc ^
201b2e6c ^



6f5d7864 ^
201b2e6c ^

6f5d7864 ^
57699011 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
                   
 
                                             
     

                                        

                                                
                                                                                   

                                                                      


        
                                      



                             
                        
                       
                        
                             
 
                         
             




                               


                        
 

                                             

                                        

                                                
                                                                       





                                                
                                                                                  

                                                                      


        
                   



                              
                        

                              
                        
                             
 
                               



                               
                        
                          
                        
                               
 

                                             

                                           

                                                
                                                                       





                                                
                                                                                  

                                                                      


        
                       



                                
                        

                              
                        
                             
 
                                   



                                  
                        

                              
                        
                               
//: Jump primitives

:(before "End Primitive Recipe Declarations")
JUMP,
:(before "End Primitive Recipe Numbers")
Recipe_number["jump"] = JUMP;
:(before "End Primitive Recipe Implementations")
case JUMP: {
  trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].value;
  current_step_index() += current_instruction().ingredients[0].value;
  trace("run") << "jumping to instruction " << current_step_index()+1;
  break;
}

:(scenario jump_can_skip_instructions)
recipe main [
  jump 1:offset
  1:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 0 is 1
-run: instruction main/1
-mem: storing 1 in location 1

:(scenario jump_backward)
recipe main [
  jump 1:offset  # 0 -+
  jump 1:offset  #    |   +-+ 1
                 #   \/  /\ |
  jump -2:offset #  2 +-->+ |
]                #         \/ 3
+run: instruction main/0
+run: instruction main/2
+run: instruction main/1

:(before "End Primitive Recipe Declarations")
JUMP_IF,
:(before "End Primitive Recipe Numbers")
Recipe_number["jump-if"] = JUMP_IF;
:(before "End Primitive Recipe Implementations")
case JUMP_IF: {
  vector<int> arg0 = read_memory(current_instruction().ingredients[0]);
  assert(arg0.size() == 1);
  trace("run") << "ingredient 0 is " << arg0[0];
  if (!arg0[0]) {
    trace("run") << "jump-if fell through";
    break;
  }
  trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
  current_step_index() += current_instruction().ingredients[1].value;
  trace("run") << "jumping to instruction " << current_step_index()+1;
  break;
}

:(scenario jump_if)
recipe main [
  jump-if 999:literal 1:offset
  1:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 1 is 1
+run: jumping to instruction 2
-run: instruction main/1
-mem: storing 1 in location 1

:(scenario jump_if_fallthrough)
recipe main [
  jump-if 0:literal 1:offset
  123:integer <- copy 1:literal
]
+run: instruction main/0
+run: jump-if fell through
+run: instruction main/1
+mem: storing 1 in location 123

:(before "End Primitive Recipe Declarations")
JUMP_UNLESS,
:(before "End Primitive Recipe Numbers")
Recipe_number["jump-unless"] = JUMP_UNLESS;
:(before "End Primitive Recipe Implementations")
case JUMP_UNLESS: {
  vector<int> arg0 = read_memory(current_instruction().ingredients[0]);
  assert(arg0.size() == 1);
  trace("run") << "ingredient 0 is " << arg0[0];
  if (arg0[0]) {
    trace("run") << "jump-unless fell through";
    break;
  }
  trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
  current_step_index() += current_instruction().ingredients[1].value;
  trace("run") << "jumping to instruction " << current_step_index()+1;
  break;
}

:(scenario jump_unless)
recipe main [
  jump-unless 0:literal 1:offset
  1:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 1 is 1
+run: jumping to instruction 2
-run: instruction main/1
-mem: storing 1 in location 1

:(scenario jump_unless_fallthrough)
recipe main [
  jump-unless 999:literal 1:offset
  123:integer <- copy 1:literal
]
+run: instruction main/0
+run: ingredient 0 is 999
+run: jump-unless fell through
+run: instruction main/1
+mem: storing 1 in location 123