summary refs log blame commit diff stats
path: root/doc/rifle.1
blob: 6395a34d76bc88570131e832af396feb19d5ee3e (plain) (tree)
1
                                                               






































                                                                              

          









                                                                              


                                                          
  





                                    
  




                      
   
      
































































                                                                                           
                                                     





























































                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                 





                                                                                         






                                

                                                     




                                

                                                                        




                              

                                                               



                                     
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "RIFLE 1"
.TH RIFLE 1 "rifle-1.6.1" "06/21/2013" "rifle manual"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
rifle \- ranger's file opener
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBrifle\fR [\fB\-\-help\fR] [\fB\-f\fR \fI\s-1FLAGS\s0\fR] [\fB\-l\fR] [\fB\-p\fR \fI\s-1KEYWORD\s0\fR]
[\fB\-w\fR \fI\s-1PROGRAM\s0\fR] \fIfiles\fR
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
rifle is a powerful file executor that allows for complex file type checking,
written to meet the needs of the file manager \fIranger\fR.  rifle's strength lies
in automatically determining file types, depending on which programs are
installed on the system, even without any user interaction.
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-f\fR \fI\s-1FLAGS\s0\fR" 14
.IX Item "-f FLAGS"
Specify flags for opening the files.  Flags are letters that changes how the
program is executed.  Any combination of flags will work.  Writing uppercase
flags will negate the effect of all previously used lowercase flags of the same
letter.
.Sp
Table of all flags:
 f   fork program to background
 r   run program as root, using sudo
 t   run program in a separate terminal, as specified by \f(CW$TERMCMD\fR
.IP "\fB\-l\fR" 14
.IX Item "-l"
List all possible ways to open the specified files.  Each line will contain information in the format of \fIid:label:flags:command\fR. \fIid\fR is the identification number. \fIlabel\fR is an arbitrary string that was specified for this command, \fIflags\fR are the flags that are used by default, and \fIcommand\fR is the command that is going to be executed.
.IP "\fB\-p\fR \fI\s-1KEYWORD\s0\fR" 14
.IX Item "-p KEYWORD"
Pick a method to open the files.
.Sp
\&\fI\s-1KEYWORD\s0\fR is either the \s-1ID\s0 number listed by \f(CW\*(C`rifle \-l\*(C'\fR or a string that matches a label in the configuration file.
.IP "\fB\-w\fR \fI\s-1PROGRAM\s0\fR" 14
.IX Item "-w PROGRAM"
Open the files with the program \fI\s-1PROGRAM\s0\fR
.IP "\fB\-h\fR, \fB\-\-help\fR" 14
.IX Item "-h, --help"
Print a list of options and exit.
.SH "FILES"
.IX Header "FILES"
rifle shares configuration files with ranger, though ranger is not required in
order to use rifle.  The configuration file \fIrifle.conf\fR is expected to be at
\&\fI~/.config/ranger/rifle.conf\fR.
.PP
This file specifies patterns for determining the commands to open files with.
The syntax is described in the comments of the default \fIrifle.conf\fR that ships
with ranger.  To obtain it, you need to run: \f(CW\*(C`ranger \-\-copy\-config=rifle\*(C'\fR
.SH "ENVIRONMENT"
.IX Header "ENVIRONMENT"
.IP "\s-1EDITOR\s0" 8
.IX Item "EDITOR"
Determines which editor to use for editing files (in the default \fIrifle.conf\fR).
.IP "\s-1PAGER\s0" 8
.IX Item "PAGER"
Determines which pager to use for displaying files (in the default \fIrifle.conf\fR).
.IP "\s-1TERMCMD\s0" 8
.IX Item "TERMCMD"
Determines the terminal emulator command for use with the \fIt\fR flag.  It is required that the value is the path to an executable file which accepts the \*(L"\-e \s-1COMMAND\*(R"\s0 argument.
.IP "\s-1XDG_CONFIG_HOME\s0" 8
.IX Item "XDG_CONFIG_HOME"
Specifies the directory for configuration files. Defaults to \fI\f(CI$HOME\fI/.config\fR.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
List all the different methods:
.PP
.Vb 4
\& $ rifle \-l helloworld.py
\& 0:editor::"$EDITOR" \-\- "$@"
\& 1:pager::"$PAGER" \-\- "$@"
\& 2:::python \-\- "$1"
.Ve
.PP
Display its content by opening it with \*(L"cat\*(R":
.PP
.Vb 2
\& $ rifle \-w cat helloworld.py
\& print("Hello World!")
.Ve
.PP
Run it by picking the method 2, which calls 'python \*(-- \*(L"$1\*(R"':
.PP
.Vb 2
\& $ rifle \-p 2 helloworld.py
\& Hello World!
.Ve
.PP
Display the file in a pager inside a new terminal, run as root:
.PP
.Vb 1
\& $ rifle \-p 1 \-f tr helloworld.py
.Ve
u/blame/069hash.cc?h=main&id=e24799ead45d9d4a86d8e8ab051dd16e1e417431'>^
37421f8a ^





7a84094a ^
08f4628e ^
760f683f ^
37421f8a ^
1ead3562 ^
760f683f ^


7a84094a ^

760f683f ^


7a84094a ^


37421f8a ^





7a84094a ^
08f4628e ^
37421f8a ^


7a84094a ^

37421f8a ^
1ead3562 ^
37421f8a ^
7a84094a ^

37421f8a ^
7a84094a ^


37421f8a ^






7a84094a ^
37421f8a ^

7a84094a ^

37421f8a ^
1ead3562 ^
37421f8a ^
7a84094a ^

37421f8a ^
7a84094a ^


37421f8a ^








1ead3562 ^
d559f68b ^
23d3a022 ^


37421f8a ^
23d3a022 ^
37421f8a ^







2b250717 ^
37421f8a ^

78c50205 ^
0f2781f8 ^
d5fe534d ^




37421f8a ^
23d3a022 ^
d5fe534d ^

6c96a437 ^
d5fe534d ^












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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
                                          








                                                                              






                                             
                                                                                                                                             

          



                                                
                                                                 







                                                                                       
                                          
              
                                     
                              



















                                                                          
                                                                                                             
                                              
                               


                    
                                                 
                                                                                 
                                           






                                                       
                                            
                           
                   
                                         
                                                                                 
                               
                           





                                                           
                                                      
                                                            

                        
                                                   
                                                      
                                                           


                                       
                                                



           
                                                                
                                                
                      
                                 
                                                 
                                                       
                                               
                                                                                                               

















                                              
       
        
 
          
                         

                     
                         


                              






                                                        
       

               

       
 
          
                            

                     
                            


                              



                                          

                                              
       
                        
 
          
                         

                     
                         


                              



                                         



                                                                       
          
                      
                       





                                                                            
          


                              



                                        
          



                   
                               
                     
                     


                              



                                      
          





                            
                              



                                                                                      

                                                   
       
        

               
       
        
 
          
                         

                     
                         


                              





                                                            
       
        
         
 
          


                                  

                     


                                  


                                





                                                                   
       
        


               

       
 
          
                                 

                     
                                 


                                






                                                                   
       

               

       
 
          
                            

                     
                       


                              








                                                                       
          
                     


                              
 
                             







                                             
                                                                                                                                                 

          
                                            
                                                                                                                                                                                       




                                                
                
                                                                        

                
                                           












                                          
// Compute a hash for objects of any type.
//
// The way it's currently implemented, two objects will have the same hash if
// all their non-address fields (all the way down) expand to the same sequence
// of scalar values. In particular, a container with all zero addresses hashes
// to 0. Hopefully this won't be an issue because we are usually hashing
// objects of a single type in any given hash table.
//
// Based on http://burtleburtle.net/bob/hash/hashfaq.html

:(before "End Primitive Recipe Declarations")
HASH,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "hash", HASH);
:(before "End Primitive Recipe Checks")
case HASH: {
  if (SIZE(inst.ingredients) != 1) {
    raise << maybe(get(Recipe, r).name) << "'hash' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case HASH: {
  const reagent& input = current_instruction().ingredients.at(0);
  products.resize(1);
  products.at(0).push_back(hash(0, input));
  break;
}

//: in all the code below, the intermediate results of hashing are threaded through 'h'

:(code)
size_t hash(size_t h, reagent/*copy*/ r) {
  canonize(r);
  if (is_mu_text(r))  // optimization
    return hash_mu_text(h, r);
  else if (is_mu_address(r))
    return hash_mu_address(h, r);
  else if (is_mu_scalar(r))
    return hash_mu_scalar(h, r);
  else if (is_mu_array(r))
    return hash_mu_array(h, r);
  else if (is_mu_container(r))
    return hash_mu_container(h, r);
  else if (is_mu_exclusive_container(r))
    return hash_mu_exclusive_container(h, r);
  assert(false);
}

size_t hash_mu_scalar(size_t h, const reagent& r) {
  double input = is_literal(r) ? r.value : get_or_insert(Memory, r.value);
  return hash_iter(h, static_cast<size_t>(input));
}

size_t hash_mu_address(size_t h, reagent& r) {
  if (r.value == 0) return 0;
  trace("mem") << "location " << r.value << " is " << no_scientific(get_or_insert(Memory, r.value)) << end();
  r.set_value(get_or_insert(Memory, r.value));
  drop_from_type(r, "address");
  return hash(h, r);
}

size_t hash_mu_text(size_t h, const reagent& r) {
  string input = read_mu_text(get_or_insert(Memory, r.value+/*skip alloc id*/1));
  for (int i = 0;  i < SIZE(input);  ++i) {
    h = hash_iter(h, static_cast<size_t>(input.at(i)));
//?     cerr << i << ": " << h << '\n';
  }
  return h;
}

size_t hash_mu_array(size_t h, const reagent& r) {
  int size = get_or_insert(Memory, r.value);
  reagent/*copy*/ elem = r;
  delete elem.type;
  elem.type = copy_array_element(r.type);
  for (int i=0, address = r.value+1;  i < size;  ++i, address += size_of(elem)) {
    reagent/*copy*/ tmp = elem;
    tmp.set_value(address);
    h = hash(h, tmp);
//?     cerr << i << " (" << address << "): " << h << '\n';
  }
  return h;
}

size_t hash_mu_container(size_t h, const reagent& r) {
  type_info& info = get(Type, get_base_type(r.type)->value);
  int address = r.value;
  int offset = 0;
  for (int i = 0;  i < SIZE(info.elements);  ++i) {
    reagent/*copy*/ element = element_type(r.type, i);
    if (has_property(element, "ignore-for-hash")) continue;
    element.set_value(address+offset);
    h = hash(h, element);
//?     cerr << i << ": " << h << '\n';
    offset += size_of(info.elements.at(i).type);
  }
  return h;
}

size_t hash_mu_exclusive_container(size_t h, const reagent& r) {
  const type_tree* type = get_base_type(r.type);
  assert(type->value);
  int tag = get(Memory, r.value);
  reagent/*copy*/ variant = variant_type(r, tag);
  // todo: move this error to container definition time
  if (has_property(variant, "ignore-for-hash"))
    raise << get(Type, type->value).name << ": /ignore-for-hash won't work in exclusive containers\n" << end();
  variant.set_value(r.value + /*skip tag*/1);
  h = hash(h, variant);
  return h;
}

size_t hash_iter(size_t h, size_t input) {
  h += input;
  h += (h<<10);
  h ^= (h>>6);

  h += (h<<3);
  h ^= (h>>11);
  h += (h<<15);
  return h;
}

:(scenario hash_container_checks_all_elements)
container foo [
  x:num
  y:char
]
def main [
  1:foo <- merge 34, 97/a
  3:num <- hash 1:foo
  return-unless 3:num
  4:foo <- merge 34, 98/a
  6:num <- hash 4:foo
  return-unless 6:num
  7:bool <- equal 3:num, 6:num
]
# hash on containers includes all elements
+mem: storing 0 in location 7

:(scenario hash_exclusive_container_checks_all_elements)
exclusive-container foo [
  x:bar
  y:num
]
container bar [
  a:num
  b:num
]
def main [
  1:foo <- merge 0/x, 34, 35
  4:num <- hash 1:foo
  return-unless 4:num
  5:foo <- merge 0/x, 34, 36
  8:num <- hash 5:foo
  return-unless 8:num
  9:bool <- equal 4:num, 8:num
]
# hash on containers includes all elements
+mem: storing 0 in location 9

:(scenario hash_can_ignore_container_elements)
container foo [
  x:num
  y:char/ignore-for-hash
]
def main [
  1:foo <- merge 34, 97/a
  3:num <- hash 1:foo
  return-unless 3:num
  4:foo <- merge 34, 98/a
  6:num <- hash 4:foo
  return-unless 6:num
  7:bool <- equal 3:num, 6:num
]
# hashes match even though y is different
+mem: storing 1 in location 7

//: These properties aren't necessary for hash, they just test that the
//: current implementation works like we think it does.

:(scenario hash_of_zero_address)
def main [
  1:&:num <- copy null
  2:num <- hash 1:&:num
]
+mem: storing 0 in location 2

//: This is probably too aggressive, but we need some way to avoid depending
//: on the precise bit pattern of a floating-point number.
:(scenario hash_of_numbers_ignores_fractional_part)
def main [
  1:num <- hash 1.5
  2:num <- hash 1
  3:bool <- equal 1:num, 2:num
]
+mem: storing 1 in location 3

:(scenario hash_of_array_same_as_string)
def main [
  10:num <- copy 3
  11:num <- copy 97
  12:num <- copy 98
  13:num <- copy 99
  2:num <- hash 10:@:num/unsafe
  return-unless 2:num
  3:text <- new [abc]
  4:num <- hash 3:text
  return-unless 4:num
  5:bool <- equal 2:num, 4:num
]
+mem: storing 1 in location 5

:(scenario hash_ignores_address_value)
def main [
  1:&:num <- new number:type
  *1:&:num <- copy 34
  2:num <- hash 1:&:num
  3:&:num <- new number:type
  *3:&:num <- copy 34
  4:num <- hash 3:&:num
  5:bool <- equal 2:num, 4:num
]
# different addresses hash to the same result as long as the values the point to do so
+mem: storing 1 in location 5

:(scenario hash_container_depends_only_on_elements)
container foo [
  x:num
  y:char
]
container bar [
  x:num
  y:char
]
def main [
  1:foo <- merge 34, 97/a
  3:num <- hash 1:foo
  return-unless 3:num
  4:bar <- merge 34, 97/a
  6:num <- hash 4:bar
  return-unless 6:num
  7:bool <- equal 3:num, 6:num
]
# containers with identical elements return identical hashes
+mem: storing 1 in location 7

:(scenario hash_container_depends_only_on_elements_2)
container foo [
  x:num
  y:char
  z:&:num
]
def main [
  1:&:num <- new number:type
  *1:&:num <- copy 34
  2:foo <- merge 34, 97/a, 1:&:num
  5:num <- hash 2:foo
  return-unless 5:num
  6:&:num <- new number:type
  *6:&:num <- copy 34
  7:foo <- merge 34, 97/a, 6:&:num
  10:num <- hash 7:foo
  return-unless 10:num
  11:bool <- equal 5:num, 10:num
]
# containers with identical 'leaf' elements return identical hashes
+mem: storing 1 in location 11

:(scenario hash_container_depends_only_on_elements_3)
container foo [
  x:num
  y:char
  z:bar
]
container bar [
  x:num
  y:num
]
def main [
  1:foo <- merge 34, 97/a, 47, 48
  6:num <- hash 1:foo
  return-unless 6:num
  7:foo <- merge 34, 97/a, 47, 48
  12:num <- hash 7:foo
  return-unless 12:num
  13:bool <- equal 6:num, 12:num
]
# containers with identical 'leaf' elements return identical hashes
+mem: storing 1 in location 13

:(scenario hash_exclusive_container_ignores_tag)
exclusive-container foo [
  x:bar
  y:num
]
container bar [
  a:num
  b:num
]
def main [
  1:foo <- merge 0/x, 34, 35
  4:num <- hash 1:foo
  return-unless 4:num
  5:bar <- merge 34, 35
  7:num <- hash 5:bar
  return-unless 7:num
  8:bool <- equal 4:num, 7:num
]
# hash on containers includes all elements
+mem: storing 1 in location 8

//: An older version that supported only strings.
//: Hash functions are subtle and easy to get wrong, so we keep the old
//: version around and check that the new one is consistent with it.

:(scenario hash_matches_old_version)
def main [
  1:text <- new [abc]
  3:num <- hash 1:text
  4:num <- hash_old 1:text
  5:bool <- equal 3:num, 4:num
]
+mem: storing 1 in location 5

:(before "End Primitive Recipe Declarations")
HASH_OLD,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "hash_old", HASH_OLD);
:(before "End Primitive Recipe Checks")
case HASH_OLD: {
  if (SIZE(inst.ingredients) != 1) {
    raise << maybe(get(Recipe, r).name) << "'hash_old' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end();
    break;
  }
  if (!is_mu_text(inst.ingredients.at(0))) {
    raise << maybe(get(Recipe, r).name) << "'hash_old' currently only supports texts (address array character), but got '" << inst.ingredients.at(0).original_string << "'\n" << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case HASH_OLD: {
  string input = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1));
  size_t h = 0 ;

  for (int i = 0;  i < SIZE(input);  ++i) {
    h += static_cast<size_t>(input.at(i));
    h += (h<<10);
    h ^= (h>>6);

    h += (h<<3);
    h ^= (h>>11);
    h += (h<<15);
  }

  products.resize(1);
  products.at(0).push_back(h);
  break;
}