annotate extract__.c @ 1630:d0efa3ae5522 default tip

run/mini/naked_asm5: New x86_64 ABI passes the arguments in reverse order.
author David Nadlinger <code@klickverbot.at>
date Sat, 23 Apr 2011 22:57:32 +0200
parents 6cd84461e17b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
1 /* svn://svn.kuehne.cn/dstress/extract__.c
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
2 *
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
3 * extract compiler flags for DStress test cases
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents: 239
diff changeset
4 * [deprecated: use dstress.c]
82
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
5 *
239
c2a96b326f61 repos & copyright maintenance
thomask
parents: 82
diff changeset
6 * Copyright (C) 2004, 2005 Thomas Kuehne
82
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
7 *
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
11 * (at your option) any later version.
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
12 *
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
16 * GNU General Public License for more details.
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
17 *
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
21 */
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
22
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
23 #include <stdio.h>
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
24 #include <stdlib.h>
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
25 #include <string.h>
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
26 #include <errno.h>
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
27
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
28 // @WARNING@ works only with ASCII / UTF-8 source files
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
29 int main(int argc, char* argv[]){
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
30 if(argc!=2){
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
31 printf("this stdin will be queried for the patter given as first argument\n");
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
32 return -1;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
33 }
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
34
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
35 // the longest source line in the test is a bit over 1<<16 bytes long
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
36 size_t length = 1 << 17;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
37 char* line = malloc(length);
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
38 char* buffer;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
39 char* found;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
40 char* pattern=argv[1];
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
41 size_t pattern_length=strlen(pattern);
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
42
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
43 errno=0;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
44 while(buffer=fgets(line, length, stdin)){
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
45 found = strstr(buffer, pattern);
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
46
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
47 if(errno!=0){
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
48 break;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
49 }else if(found!=NULL){
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
50 found+=pattern_length;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
51 printf("%s", found);
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
52 break;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
53 }
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
54 }
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
55
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
56 free(line);
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
57
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
58 return 0;
94b746f24b50 added ?DSTRESS_FLAGS? support
thomask
parents:
diff changeset
59 }