- Timestamp:
- Dec 7, 2021, 9:16:27 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 58e0d3c
- Parents:
- 130a778
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/as.cc
r130a778 r88792f3 11 11 // Created On : Wed Aug 1 10:49:42 2018 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Dec 7 2 0:49:15 202114 // Update Count : 1 2113 // Last Modified On : Tue Dec 7 21:15:25 2021 14 // Update Count : 132 15 15 // 16 16 … … 18 18 #include <cstdlib> // exit 19 19 #include <fcntl.h> // open 20 #include <unistd.h> 21 #include <sys/stat.h> 20 #include <cstring> // strstr, memmove 21 #include <unistd.h> // ftruncate,execvp 22 #include <sys/stat.h> // fstat 22 23 #include <sys/mman.h> // mmap 23 #include <string.h>24 24 25 25 //#define __DEBUG_H__ 26 27 #ifdef __DEBUG_H__28 #include <iostream>29 using namespace std;30 #endif // __DEBUG_H__31 26 32 27 int main( const int argc, const char * argv[] ) { 33 28 #ifdef __DEBUG_H__ 34 29 for ( int i = 0; i < argc; i += 1 ) { 35 cerr << argv[i] << endl;30 fprintf( stderr, "%s\n", argv[i] ); 36 31 } // for 37 32 #endif // __DEBUG_H__ … … 56 51 } // for 57 52 cursor -= 1; // backup over '\n' 58 if ( (*(cursor - 3) == '0' && *(cursor - 2) == 'x' && *(cursor - 1) == 'c') ) { // 0xc => C99 53 // From elfcpp/dwarf.h in the binutils source tree. 54 // DW_LANG_C89 = 0x1, DW_LANG_C = 0x2, DW_LANG_C99 = 0xc, DW_LANG_C11 = 0x1d 55 if ( *(cursor - 3) == '0' && *(cursor - 2) == 'x' && 56 (*(cursor - 1) == 'c' || *(cursor - 1) == '1' || *(cursor - 1) == '2') ) { // C89/C/C99 59 57 // Expand file by one byte to hold 2 character Cforall language code. 60 58 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); }; 61 59 memmove( cursor + 1, cursor, start + size - cursor ); // move remaining text 1 character right 62 } else if ( *(cursor - 4) == '0' && *(cursor - 3) == 'x' && *(cursor - 2) == '1' && *(cursor - 1) == 'd' ) { // 0x1d => C11 63 // replace "1d" with "25" 60 } else if ( *(cursor - 4) == '0' && *(cursor - 3) == 'x' && *(cursor - 2) == '1' && *(cursor - 1) == 'd' ) { // C11 64 61 } else { 65 62 for ( int i = 0; i < 6; i += 1 ) { // move N (magic) lines forward … … 72 69 } // if 73 70 74 *(cursor - 2) = '2'; // replace C /C11 language value with CFA71 *(cursor - 2) = '2'; // replace C89/C/C99/C11 language code with CFA code 75 72 *(cursor - 1) = '5'; 76 73 } // if
Note: See TracChangeset
for help on using the changeset viewer.