Commit ff8de69fcfc8f663b55a7c2c47d1ea8caecd6e86

Authored by David René
1 parent 43565b22

move the to_upper and to_lower functions to system/string.anubis location

anubis_dev/library/system/files.anubis
... ... @@ -193,7 +193,8 @@ public define ResultCopy
193 193 truncated(buffer) then
194 194 if length(buffer) = 0 then
195 195 copy_ok
196   - else if write( target , buffer) is
  196 + else
  197 + if write( target , buffer) is
197 198 {
198 199 failure then copy_error,
199 200 success(_) then copy_ok
... ...
anubis_dev/library/system/string.anubis
... ... @@ -33,6 +33,19 @@
33 33 read tools/basis.anubis
34 34 read tools/findstring.anubis
35 35  
  36 +
  37 +
  38 + 'crlf' is a string which is required by the HTTP protocol to mark the end of a
  39 + line. Any HTTP request or HTTP answer has two parts (the second one may be empty): the
  40 + header and the body. The header is made of several lines (at least one), and separated
  41 + from the body by a blank line. In other words, the header is separated from the body by
  42 + a ''double crlf''.
  43 +
  44 +public define String crlf = implode([(Word8)13,10]). i.e ASCII characters: 13 10 (in this order)
  45 +public define String crlfcrlf = implode([(Word8)13,10,13,10]).
  46 +
  47 +
  48 +
36 49 define String
37 50 zero_pad_n
38 51 (
... ... @@ -44,6 +57,49 @@ define String
44 57 else
45 58 number.
46 59  
  60 +public define Word8
  61 + to_lower
  62 + (
  63 + Word8 c
  64 + ) =
  65 + with n = word8_to_int32(c),
  66 + if ('A' =< n & n =< 'Z')
  67 + then truncate_to_word8(n - 'A' + 'a')
  68 + else c.
  69 +
  70 +public define Word8
  71 + to_upper
  72 + (
  73 + Word8 c
  74 + ) =
  75 + with n = word8_to_int32(c),
  76 + if ('a' =< n & n =< 'z')
  77 + then truncate_to_word8(n - 'a' + 'A')
  78 + else c.
  79 +
  80 + Putting a string to lower case.
  81 +
  82 +define String
  83 + to_lower
  84 + (
  85 + String s,
  86 + Int32 n,
  87 + List(Word8) so_far
  88 + ) =
  89 + if nth(n,s) is
  90 + {
  91 + failure then implode(reverse(so_far)),
  92 + success(c) then
  93 + to_lower(s,n+1,[to_lower(c) . so_far])
  94 + }.
  95 +
  96 +public define String
  97 + to_lower
  98 + (
  99 + String s
  100 + ) =
  101 + to_lower(s,0,[]).
  102 +
47 103 public define String
48 104 zero_pad_n
49 105 (
... ...
anubis_dev/library/tools/basis.anubis
... ... @@ -102,7 +102,6 @@
102 102 *** (13) Manipulating characters
103 103 *** (13.1) Putting a character to lower case.
104 104 *** (13.2) Putting a string to lower case.
105   - *** (13.3) 'crlf'
106 105  
107 106 *** (14) Prompting and reading from standard input.
108 107 *** (14.1) Reading a line from the standard input.
... ... @@ -117,7 +116,6 @@
117 116 *** (16.3) System font names
118 117  
119 118 ---------------------------------------------------------------------------------------
120   -
121 119  
122 120 *** (1) Boolean functions
123 121  
... ... @@ -2175,78 +2173,6 @@ public define List(String)
2175 2173 +
2176 2174 get_more_files(directory_name,file_name_mask,directory_full_list(directory_name,"","","*")).
2177 2175  
2178   -
2179   -
2180   -
2181   - *** (13) Manipulating characters
2182   -
2183   - *** (13.1) Putting a character to lower case.
2184   -
2185   -public define Word8
2186   - to_lower
2187   - (
2188   - Word8 c
2189   - ) =
2190   - with n = word8_to_int32(c),
2191   - if ('A' =< n & n =< 'Z')
2192   - then truncate_to_word8(n - 'A' + 'a')
2193   - else c.
2194   -
2195   -public define Word8
2196   - to_upper
2197   - (
2198   - Word8 c
2199   - ) =
2200   - with n = word8_to_int32(c),
2201   - if ('a' =< n & n =< 'z')
2202   - then truncate_to_word8(n - 'a' + 'A')
2203   - else c.
2204   -
2205   -
2206   - *** (13.2) Putting a string to lower case.
2207   -
2208   -define String
2209   - to_lower
2210   - (
2211   - String s,
2212   - Int32 n,
2213   - List(Word8) so_far
2214   - ) =
2215   - if nth(n,s) is
2216   - {
2217   - failure then implode(reverse(so_far)),
2218   - success(c) then
2219   - to_lower(s,n+1,[to_lower(c) . so_far])
2220   - }.
2221   -
2222   -
2223   -public define String
2224   - to_lower
2225   - (
2226   - String s
2227   - ) =
2228   - to_lower(s,0,[]).
2229   -
2230   -
2231   -
2232   -
2233   - *** (13.3) 'crlf'
2234   -
2235   - 'crlf' is a string which is required by the HTTP protocol to mark the end of a
2236   - line. Any HTTP request or HTTP answer has two parts (the second one may be empty): the
2237   - header and the body. The header is made of several lines (at least one), and separated
2238   - from the body by a blank line. In other words, the header is separated from the body by
2239   - a ''double crlf''.
2240   -
2241   -public define String
2242   - crlf = implode([(Word8)13,10]). i.e ASCII characters: 13 10 (in this order)
2243   -
2244   -public define String crlfcrlf = implode([(Word8)13,10,13,10]).
2245   -
2246   -
2247   -
2248   -
2249   -
2250 2176 *** (14) Prompting and reading from standard input.
2251 2177  
2252 2178 *** (14.1) Reading a line from the standard input.
... ...
anubis_dev/library/web/multihost_http_server.anubis
... ... @@ -163,7 +163,7 @@
163 163 read web/common.anubis
164 164 read tools/basis.anubis
165 165 read web/mime.anubis
166   -
  166 +read system/string.anubis
167 167  
168 168  
169 169 *** (4) Site descriptions.
... ...