415161536e957d2c4b0bdeb60d5bb83a8f3cd658
[cacao.git] / src / cacaoh / headers.c
1 /* src/cacaoh/headers.c - functions for header generation
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Reinhard Grafl
28
29    Changes: Mark Probst
30             Philipp Tomsich
31             Christian Thalinger
32
33    $Id: headers.c 4150 2006-01-12 21:11:00Z twisti $
34
35 */
36
37
38 #include <assert.h>
39 #include <ctype.h>
40 #include <stdarg.h>
41 #include <stdlib.h>
42 #include <string.h>
43
44 #include "config.h"
45 #include "vm/types.h"
46
47 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
48 # if defined(__DARWIN__)
49 #  include <signal.h>
50 # endif
51 # include <ucontext.h>
52 #endif
53
54 #include "mm/boehm.h"
55 #include "mm/memory.h"
56 #include "native/include/java_lang_String.h"
57 #include "native/include/java_lang_Throwable.h"
58 #include "toolbox/chain.h"
59 #include "toolbox/logging.h"
60 #include "vm/builtin.h"
61 #include "vm/class.h"
62 #include "vm/global.h"
63 #include "vm/method.h"
64 #include "vm/loader.h"
65 #include "vm/options.h"
66 #include "vm/stringlocal.h"
67 #include "vm/jit/asmpart.h"
68
69
70 #if defined(ENABLE_INTRP)
71 /* dummy interpreter stack to keep the compiler happy */
72
73 u1 intrp_main_stack[1];
74 #endif
75
76
77 /* for raising exceptions from native methods *********************************/
78
79 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
80 java_objectheader *_no_threads_exceptionptr = NULL;
81 #endif
82
83
84 /* replace some non-vmcore functions ******************************************/
85
86 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
87                                                                 bool isstatic)
88 {
89         /* return something different than NULL, otherwise we get an exception */
90
91         return (functionptr) 1;
92 }
93
94 java_objectheader *native_new_and_init(classinfo *c) { return NULL; }
95 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s) { return NULL; }
96 java_objectheader *native_new_and_init_int(classinfo *c, s4 i) { return NULL; }
97 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t) { return NULL; }
98
99
100 #if defined(ENABLE_JIT)
101 java_objectheader *asm_calljavafunction(methodinfo *m,
102                                                                                 void *arg1, void *arg2,
103                                                                                 void *arg3, void *arg4)
104 { return NULL; }
105 #endif
106
107 #if defined(ENABLE_INTRP)
108 java_objectheader *intrp_asm_calljavafunction(methodinfo *m,
109                                                                                           void *arg1, void *arg2,
110                                                                                           void *arg3, void *arg4)
111 { return NULL; }
112 #endif
113
114
115 /* code patching functions */
116 void patcher_builtin_arraycheckcast(u1 *sp) {}
117
118 #if defined(__MIPS__)
119 long compare_and_swap(long *p, long oldval, long newval)
120 {
121         if (*p == oldval) {
122                 *p = newval;
123                 return oldval;
124         } else
125                 return *p;
126 }
127 #endif
128
129
130 u1 *createcompilerstub(methodinfo *m) { return NULL; }
131 #if defined(ENABLE_INTRP)
132 u1 *intrp_createcompilerstub(methodinfo *m) { return NULL; }
133 #endif
134
135 u1 *codegen_createnativestub(functionptr f, methodinfo *m) { return NULL; }
136
137 void removecompilerstub(u1 *stub) {}
138 void removenativestub(u1 *stub) {}
139
140 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop) {}
141 u1* asm_initialize_thread_stack(void *func, u1 *stack) { return NULL; }
142
143 void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p) { return NULL; }
144
145 void asm_handle_builtin_exception(classinfo *c) {}
146
147
148 #if defined(ENABLE_JIT)
149 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out) {}
150 #endif
151
152 #if defined(ENABLE_INTRP)
153 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out) {}
154 #endif
155
156
157 void *Java_java_lang_VMObject_clone(void *env, void *clazz, void * this)
158 {
159         return NULL;
160 }
161
162 typecheck_result typeinfo_is_assignable_to_class(typeinfo *value,classref_or_classinfo dest)
163 {
164         return typecheck_TRUE;
165 }
166
167 void typeinfo_init_classinfo(typeinfo *info,classinfo *c)
168 {
169 }
170
171 bool typeinfo_init_class(typeinfo *info,classref_or_classinfo c)
172 {
173         return true;
174 }
175
176 void typeinfo_print(FILE *file,typeinfo *info,int indent) {}
177
178 void exceptions_print_exception(java_objectheader *xptr) {}
179 void stacktrace_print_trace(java_objectheader *xptr) {}
180
181
182 /* exception functions ********************************************************/
183
184 /* these should not be called */
185
186 void throw_main_exception_exit(void) { assert(0); }
187 void throw_exception(void) { assert(0); }
188 void throw_exception_exit(void) { assert(0); }
189
190 java_objectheader *new_verifyerror(methodinfo *m, const char *message)
191 {
192         assert(0);
193
194         /* keep compiler happy */
195
196         return NULL;
197 }
198
199 java_objectheader *new_exception_throwable(const char *classname, java_lang_Throwable *throwable)
200 {
201         assert(0);
202
203         /* keep compiler happy */
204
205         return NULL;
206 }
207
208
209 void throw_cacao_exception_exit(const char *exception, const char *message, ...)
210 {
211         va_list ap;
212
213         fprintf(stderr, "%s: ", exception);
214
215         va_start(ap, message);
216         vfprintf(stderr, message, ap);
217         va_end(ap);
218
219         fputc('\n', stderr);
220
221         exit(1);
222 }
223
224
225 void exceptions_throw_outofmemory_exit(void)
226 {
227         fprintf(stderr, "java.lang.InternalError: Out of memory\n");
228         exit(1);
229 }
230
231
232 java_objectheader *new_exception(const char *classname)
233 {
234         fprintf(stderr, "%s\n", classname);
235         exit(1);
236
237         /* keep compiler happy */
238
239         return NULL;
240 }
241
242
243 java_objectheader *new_exception_message(const char *classname, const char *message)
244 {
245         fprintf(stderr, "%s: %s\n", classname, message);
246         exit(1);
247
248         /* keep compiler happy */
249
250         return NULL;
251 }
252
253
254 java_objectheader *new_exception_utfmessage(const char *classname, utf *message)
255 {
256         fprintf(stderr, "%s: ", classname);
257         utf_display(message);
258         fputc('\n', stderr);
259
260         exit(1);
261
262         /* keep compiler happy */
263
264         return NULL;
265 }
266
267
268 java_objectheader *new_exception_javastring(const char *classname,
269                                                                                         java_lang_String *message)
270 {
271         fprintf(stderr, "%s: ", classname);
272         /* TODO print message */
273         fputc('\n', stderr);
274
275         exit(1);
276
277         /* keep compiler happy */
278
279         return NULL;
280 }
281
282
283 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...)
284 {
285         va_list ap;
286
287         utf_display(c->name);
288         fprintf(stderr, ": ");
289
290         va_start(ap, message);
291         vfprintf(stderr, message, ap);
292         va_end(ap);
293
294         fputc('\n', stderr);
295
296         exit(1);
297
298         /* keep compiler happy */
299
300         return NULL;
301 }
302
303
304 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
305 {
306         va_list ap;
307
308         va_start(ap, message);
309         (void) new_classformaterror(c, message, ap);
310         va_end(ap);
311 }
312
313
314 java_objectheader *new_classnotfoundexception(utf *name)
315 {
316         fprintf(stderr, "java.lang.ClassNotFoundException: ");
317         utf_fprint(stderr, name);
318         fputc('\n', stderr);
319
320         exit(1);
321
322         /* keep compiler happy */
323
324         return NULL;
325 }
326
327
328 java_objectheader *new_noclassdeffounderror(utf *name)
329 {
330         fprintf(stderr, "java.lang.NoClassDefFoundError: ");
331         utf_fprint(stderr, name);
332         fputc('\n', stderr);
333
334         exit(1);
335
336         /* keep compiler happy */
337
338         return NULL;
339 }
340
341
342 java_objectheader *exceptions_new_linkageerror(const char *message,
343                                                                                            classinfo *c)
344 {
345         fprintf(stderr, "java.lang.LinkageError: %s",message);
346         if (c) {
347                 utf_fprint_classname(stderr, c->name);
348         }
349         fputc('\n', stderr);
350
351         exit(1);
352
353         /* keep compiler happy */
354
355         return NULL;
356 }
357
358 java_objectheader *exceptions_new_nosuchmethoderror(classinfo *c,
359                                                                                                         utf *name, utf *desc)
360 {
361         fprintf(stderr, "java.lang.NoSuchMethodError: ");
362         utf_fprint(stderr, c->name);
363         fprintf(stderr, ".");
364         utf_fprint(stderr, name);
365         utf_fprint(stderr, desc);
366         fputc('\n', stderr);
367
368         exit(1);
369
370         /* keep compiler happy */
371
372         return NULL;
373 }
374
375
376 java_objectheader *new_internalerror(const char *message, ...)
377 {
378         va_list ap;
379
380         fprintf(stderr, "%s: ", string_java_lang_InternalError);
381
382         va_start(ap, message);
383         vfprintf(stderr, message, ap);
384         va_end(ap);
385
386         exit(1);
387
388         /* keep compiler happy */
389
390         return NULL;
391 }
392
393
394 java_objectheader *new_unsupportedclassversionerror(classinfo *c, const char *message, ...)
395 {
396         va_list ap;
397
398         fprintf(stderr, "%s: ", string_java_lang_UnsupportedClassVersionError);
399
400         utf_display(c->name);
401         fprintf(stderr, ": ");
402
403         va_start(ap, message);
404         vfprintf(stderr, message, ap);
405         va_end(ap);
406
407         exit(1);
408
409         /* keep compiler happy */
410
411         return NULL;
412 }
413
414
415 java_objectheader *new_illegalmonitorstateexception(void)
416 {
417         fprintf(stderr, "%s", string_java_lang_IllegalMonitorStateException);
418         exit(1);
419
420         /* keep compiler happy */
421
422         return NULL;
423 }
424
425
426 java_objectheader *new_negativearraysizeexception(void)
427 {
428         fprintf(stderr, "%s", string_java_lang_NegativeArraySizeException);
429         exit(1);
430
431         /* keep compiler happy */
432
433         return NULL;
434 }
435
436
437 void exceptions_throw_negativearraysizeexception(void)
438 {
439         (void) new_negativearraysizeexception();
440 }
441
442
443 java_objectheader *new_nullpointerexception(void)
444 {
445         fprintf(stderr, "%s", string_java_lang_NullPointerException);
446         exit(1);
447
448         /* keep compiler happy */
449
450         return NULL;
451 }
452
453
454 void exceptions_throw_nullpointerexception(void)
455 {
456         (void) new_nullpointerexception();
457 }
458
459
460 void classnotfoundexception_to_noclassdeffounderror(void)
461 {
462 }
463
464 /* machine dependent stuff ****************************************************/
465
466 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
467 threadcritnode asm_criticalsections;
468 void thread_restartcriticalsection(ucontext_t *uc) {}
469 #endif
470
471 void md_param_alloc(methoddesc *md) {}
472
473
474 #if defined(ENABLE_INTRP)
475 void print_dynamic_super_statistics(void) {}
476 #endif
477
478
479 /************************ global variables **********************/
480
481 chain *nativemethod_chain;              /* chain with native methods          */
482 chain *nativeclass_chain;               /* chain with processed classes       */
483 chain *ident_chain;     /* chain with method and field names in current class */
484 FILE *file = NULL;
485 static u4 outputsize;
486 static bool dopadding;
487
488
489 static void printIDpart(int c)
490 {
491         if ((c >= 'a' && c <= 'z') ||
492                 (c >= 'A' && c <= 'Z') ||
493                 (c >= '0' && c <= '9') ||
494                 (c == '_'))
495                 putc(c, file);
496         else
497                 putc('_', file);
498 }
499
500
501 void printID(utf *u)
502 {
503         char *utf_ptr = u->text;
504         int i;
505
506         for (i = 0; i < utf_strlen(u); i++) 
507                 printIDpart(utf_nextu2(&utf_ptr));
508 }
509
510
511 static void addoutputsize (int len)
512 {
513         u4 newsize,i;
514         if (!dopadding) return;
515
516         newsize = ALIGN(outputsize, len);
517         
518         for (i = outputsize; i < newsize; i++) fprintf(file, "   u1 pad%d\n", (int) i);
519         outputsize = newsize;
520 }
521
522
523 void printOverloadPart(utf *desc)
524 {
525         char *utf_ptr=desc->text;
526         u2 c;
527
528         fprintf(file, "__");
529
530         while ((c = utf_nextu2(&utf_ptr)) != ')') {
531                 switch (c) {
532                 case 'I':
533                 case 'S':
534                 case 'B':
535                 case 'C':
536                 case 'Z':
537                 case 'J':
538                 case 'F':
539                 case 'D': 
540                         fprintf(file, "%c", (char) c);
541                         break;
542                 case '[':
543                         fprintf(file, "_3");
544                         break;
545                 case 'L':
546                         putc('L', file);
547                         while ((c = utf_nextu2(&utf_ptr)) != ';')
548                                 printIDpart(c);
549                         fprintf(file, "_2");
550                         break;
551                 case '(':
552                         break;
553                 default: 
554                         log_text("invalid method descriptor");
555                         assert(0);
556                 }
557         }
558 }
559
560 static char *printtype(char *utf_ptr)
561 {
562         u2 c;
563
564         switch (utf_nextu2(&utf_ptr)) {
565         case 'V': fprintf (file, "void");
566                 break;
567         case 'I':
568         case 'S':
569         case 'B':
570         case 'C':
571         case 'Z': addoutputsize (4);
572                 fprintf (file, "s4");
573                 break;
574         case 'J': addoutputsize (8);
575                 fprintf (file, "s8");
576                 break;
577         case 'F': addoutputsize (4);
578                 fprintf (file, "float");
579                 break;
580         case 'D': addoutputsize (8);
581                 fprintf (file, "double");
582                 break;
583         case '[':
584                 addoutputsize ( sizeof(java_arrayheader*) ); 
585                 switch (utf_nextu2(&utf_ptr)) {
586                 case 'I':  fprintf (file, "java_intarray*"); break;
587                 case 'J':  fprintf (file, "java_longarray*"); break;
588                 case 'Z':  fprintf (file, "java_booleanarray*"); break;
589                 case 'B':  fprintf (file, "java_bytearray*"); break;
590                 case 'S':  fprintf (file, "java_shortarray*"); break;
591                 case 'C':  fprintf (file, "java_chararray*"); break;
592                 case 'F':  fprintf (file, "java_floatarray*"); break;
593                 case 'D':  fprintf (file, "java_doublearray*"); break;
594                                 
595                 case '[': fprintf(file, "java_objectarray*");
596                         while ((c = utf_nextu2(&utf_ptr)) == '[');
597                         if (c == 'L')
598                                 while (utf_nextu2(&utf_ptr) != ';');
599                         break;
600                            
601                 case 'L':  fprintf(file, "java_objectarray*");
602                         while (utf_nextu2(&utf_ptr) != ';');
603                         break;
604                 default:
605                         log_text("invalid type descriptor");
606                         assert(0);
607                 }
608                 break;
609                 
610         case 'L': 
611                 addoutputsize ( sizeof(java_objectheader*));
612                 fprintf (file, "struct ");
613                 while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);     
614                 fprintf (file, "*");
615                 break;
616                                         
617         default:
618                 log_text("Unknown type in field descriptor");
619                 assert(0);
620         }
621         
622         return utf_ptr;
623 }
624
625
626 /***** determine the number of entries of a utf string in the ident chain *****/
627
628 static int searchidentchain_utf(utf *ident) 
629 {
630         utf *u = chain_first(ident_chain);     /* first element of list */
631         int count = 0;
632
633         while (u) {
634                 if (u==ident) count++;         /* string found */
635                 u = chain_next(ident_chain);   /* next element in list */ 
636         }
637
638         return count;
639 }
640
641
642 /************** print structure for direct access to objects ******************/
643
644 static void printfields(classinfo *c)
645 {
646         u4 i;
647         fieldinfo *f;
648         int ident_count;
649         
650         if (!c) {
651                 addoutputsize(sizeof(java_objectheader));
652                 fprintf(file, "   java_objectheader header;\n");
653                 return;
654         }
655                 
656         printfields(c->super.cls);
657         
658         for (i = 0; i < c->fieldscount; i++) {
659                 f = &(c->fields[i]);
660                 
661                 if (!(f->flags & ACC_STATIC)) {
662                         fprintf(file, "   ");
663                         printtype(f->descriptor->text);
664                         fprintf(file, " ");
665                         utf_fprint(file, f->name);
666
667                         /* rename multiple fieldnames */
668                         if ((ident_count = searchidentchain_utf(f->name)))
669                                 fprintf(file, "%d", ident_count - 1);
670                         chain_addlast(ident_chain, f->name);    
671
672                         fprintf(file, ";\n");
673                 }
674         }
675 }
676
677
678 /***************** store prototype for native method in file ******************/
679
680 void printmethod(methodinfo *m)
681 {
682         char *utf_ptr;
683         u2 paramnum = 1;
684
685         /* search for return-type in descriptor */      
686         utf_ptr = m->descriptor->text;
687         while (utf_nextu2(&utf_ptr) != ')');
688
689         /* create remarks */
690         fprintf(file, "\n/*\n * Class:     ");
691         utf_fprint(file, m->class->name);
692         fprintf(file, "\n * Method:    ");
693         utf_fprint(file, m->name);
694         fprintf(file, "\n * Signature: ");
695         utf_fprint(file, m->descriptor);
696         fprintf(file, "\n */\n");
697
698         /* create prototype */                  
699         fprintf(file, "JNIEXPORT ");
700         printtype(utf_ptr);
701         fprintf(file, " JNICALL Java_");
702         printID(m->class->name);
703
704         chain_addlast(ident_chain, m->name);
705
706         fprintf(file, "_");
707         printID(m->name);
708         if (m->nativelyoverloaded) printOverloadPart(m->descriptor);
709         fprintf(file, "(JNIEnv *env");
710         
711         utf_ptr = m->descriptor->text + 1;
712                         
713         if (!(m->flags & ACC_STATIC)) {
714                 fprintf(file, ", struct ");
715                 printID(m->class->name);
716                 fprintf(file, "* this");
717
718         } else {
719                 fprintf(file, ", jclass clazz");
720         }
721
722         if ((*utf_ptr) != ')') fprintf(file, ", ");
723                         
724         while ((*utf_ptr) != ')') {
725                 utf_ptr = printtype(utf_ptr);
726                 fprintf(file, " par%d", paramnum++);
727                 if ((*utf_ptr)!=')') fprintf(file, ", ");
728         }
729                         
730         fprintf(file, ");\n\n");
731 }
732
733
734 /******* remove package-name in fully-qualified classname *********************/
735
736 void gen_header_filename(char *buffer, utf *u)
737 {
738         s4 i;
739   
740         for (i = 0; i < utf_strlen(u); i++) {
741                 if ((u->text[i] == '/') || (u->text[i] == '$')) {
742                         buffer[i] = '_';  /* convert '$' and '/' to '_' */
743
744                 } else {
745                         buffer[i] = u->text[i];
746                 }
747         }
748         buffer[utf_strlen(u)] = '\0';
749 }
750
751
752 /* create headerfile for classes and store native methods in chain ************/
753
754 void headerfile_generate(classinfo *c, char *opt_directory)
755 {
756         char header_filename[1024] = "";
757         char classname[1024]; 
758         char uclassname[1024];
759         u2 i;
760         methodinfo *m;                  
761         u2 i2;
762         methodinfo *m2;
763         u2 nativelyoverloaded;                  
764                       
765         /* store class in chain */                    
766         chain_addlast(nativeclass_chain, c);
767                                 
768         /* open headerfile for class */
769         gen_header_filename(classname, c->name);
770
771         /* create chain for renaming fields */
772         ident_chain = chain_new();
773         
774         if (opt_directory) {
775                 sprintf(header_filename, "%s/%s.h", opt_directory, classname);
776
777         } else {
778                 sprintf(header_filename, "%s.h", classname);
779         }
780
781         file = fopen(header_filename, "w");
782         if (!file) {
783                 log_text("Can not open file to store header information");
784                 assert(0);
785         }
786
787         fprintf(file, "/* This file is machine generated, don't edit it! */\n\n");
788
789         /* convert to uppercase */
790         for (i = 0; classname[i]; i++) {
791                 uclassname[i] = toupper(classname[i]);
792         }
793         uclassname[i] = '\0';
794
795         fprintf(file, "#ifndef _%s_H\n#define _%s_H\n\n", uclassname, uclassname);
796
797         /* create structure for direct access to objects */     
798         fprintf(file, "/* Structure information for class: ");
799         utf_fprint(file, c->name);
800         fprintf(file, " */\n\n");
801         fprintf(file, "typedef struct ");
802         printID(c->name);                                                       
803         fprintf(file, " {\n");
804         outputsize = 0;
805         dopadding = true;
806
807         printfields(c);
808
809         fprintf(file, "} ");
810         printID(c->name);
811         fprintf(file, ";\n\n");
812
813         /* create chain for renaming overloaded methods */
814         chain_free(ident_chain);
815         ident_chain = chain_new();
816
817         /* create method-prototypes */
818                                 
819         /* find overloaded methods */
820         for (i = 0; i < c->methodscount; i++) {
821
822                 m = &(c->methods[i]);
823
824                 if (!(m->flags & ACC_NATIVE)) continue;
825                 if (!m->nativelyoverloaded) {
826                         nativelyoverloaded=false;
827                         for (i2=i+1;i2<c->methodscount; i2++) {
828                                 m2 = &(c->methods[i2]);
829                                 if (!(m2->flags & ACC_NATIVE)) continue;
830                                 if (m->name==m2->name) {
831                                         m2->nativelyoverloaded=true;
832                                         nativelyoverloaded=true;
833                                 }
834                         }
835                         m->nativelyoverloaded=nativelyoverloaded;
836                 }
837
838         }
839
840         for (i = 0; i < c->methodscount; i++) {
841
842                 m = &(c->methods[i]);
843
844                 if (m->flags & ACC_NATIVE) {
845                         chain_addlast(nativemethod_chain, m);
846                         printmethod(m);
847                 }
848         }
849
850         chain_free(ident_chain);
851
852         fprintf(file, "#endif\n\n");
853
854         fclose(file);
855 }
856
857
858 /******** print classname, '$' used to seperate inner-class name ***********/
859
860 void print_classname(classinfo *clazz)
861 {
862         utf *u = clazz->name;
863     char *endpos  = u->text + u->blength;
864     char *utf_ptr = u->text; 
865         u2 c;
866
867     while (utf_ptr < endpos) {
868                 if ((c = utf_nextu2(&utf_ptr)) == '_')
869                         putc('$', file);
870                 else
871                         putc(c, file);
872         }
873
874
875
876 /*
877  * These are local overrides for various environment variables in Emacs.
878  * Please do not remove this and leave it at the end of the file, where
879  * Emacs will automagically detect them.
880  * ---------------------------------------------------------------------
881  * Local variables:
882  * mode: c
883  * indent-tabs-mode: t
884  * c-basic-offset: 4
885  * tab-width: 4
886  * End:
887  */