llvm.org GIT mirror llvm / 48f7ce8
Add count/not tools as executables. - Apparently, I'm willing to do incredibly stupid things in the name of portability. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82685 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 9 years ago
10 changed file(s) with 123 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
261261 add_subdirectory(test)
262262
263263 add_subdirectory(utils/FileCheck)
264 add_subdirectory(utils/count)
265 add_subdirectory(utils/not)
264266
265267 set(LLVM_ENUM_ASM_PRINTERS "")
266268 set(LLVM_ENUM_ASM_PARSERS "")
+0
-17
test/Scripts/count less more
None #!/bin/sh
1 #
2 # Program: count
3 #
4 # Synopsis: Count the number of lines of input on stdin and test that it
5 # matches the specified number.
6 #
7 # Syntax: count
8
9 set -e
10 set -u
11 input_lines=`wc -l`
12 if [ "$input_lines" -ne "$1" ]; then
13 echo "count: expected $1 lines and got ${input_lines}."
14 exit 1
15 fi
16 exit 0
+0
-12
test/Scripts/not less more
None #!/bin/sh
1 #
2 # Program: not
3 #
4 # Synopsis: Inverse the output of the program specified on the command line
5 #
6 # Syntax: not command
7
8 if "$@"
9 then exit 1
10 else exit 0
11 fi
77 ##===----------------------------------------------------------------------===##
88
99 LEVEL = ..
10 PARALLEL_DIRS := TableGen fpcmp PerfectShuffle FileCheck FileUpdate unittest
10 PARALLEL_DIRS := TableGen fpcmp PerfectShuffle FileCheck FileUpdate count not unittest
1111
1212 EXTRA_DIST := cgiplotNLT.pl check-each-file codegen-diff countloc.sh cvsupdate \
1313 DSAclean.py DSAextract.py emacs findsym.pl GenLibDeps.pl \
0 add_executable(count
1 count.c
2 )
0 ##===- utils/count/Makefile --------------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10 TOOLNAME = count
11 USEDLIBS =
12
13 # This tool has no plugins, optimize startup time.
14 TOOL_NO_EXPORTS = 1
15
16 # Don't install this utility
17 NO_INSTALL = 1
18
19 include $(LEVEL)/Makefile.common
0 /*===- count.c - The 'count' testing tool ---------------------------------===*\
1 *
2 * The LLVM Compiler Infrastructure
3 *
4 * This file is distributed under the University of Illinois Open Source
5 * License. See LICENSE.TXT for details.
6 *
7 \*===----------------------------------------------------------------------===*/
8
9 #include
10 #include
11
12 int main(int argc, char **argv) {
13 unsigned Count, NumLines, NumRead;
14 char Buffer[4096], *End;
15
16 if (argc != 2) {
17 fprintf(stderr, "usage: %s \n", argv[0]);
18 return 2;
19 }
20
21 Count = strtol(argv[1], &End, 10);
22 if (*End != '\0' && End != argv[1]) {
23 fprintf(stderr, "%s: invalid count argument '%s'\n", argv[0], argv[1]);
24 return 2;
25 }
26
27 NumLines = 0;
28 while ((NumRead = fread(Buffer, 1, sizeof(Buffer), stdin))) {
29 unsigned i;
30
31 for (i = 0; i != NumRead; ++i)
32 if (Buffer[i] == '\n')
33 ++NumLines;
34 }
35
36 if (!feof(stdin)) {
37 fprintf(stderr, "%s: error reading stdin\n", argv[0]);
38 return 3;
39 }
40
41 if (Count != NumLines) {
42 fprintf(stderr, "Expected %d lines, got %d.\n", Count, NumLines);
43 return 1;
44 }
45
46 return 0;
47 }
0 add_executable(not
1 not.cpp
2 )
3
4 target_link_libraries(not LLVMSystem)
5 if( MINGW )
6 target_link_libraries(not imagehlp psapi)
7 endif( MINGW )
8 if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
9 target_link_libraries(not pthread)
10 endif()
0 ##===- utils/not/Makefile ----------------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10 TOOLNAME = not
11 USEDLIBS = LLVMSupport.a LLVMSystem.a
12
13 # This tool has no plugins, optimize startup time.
14 TOOL_NO_EXPORTS = 1
15
16 # Don't install this utility
17 NO_INSTALL = 1
18
19 include $(LEVEL)/Makefile.common
20
0 //===- not.cpp - The 'not' testing tool -----------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/System/Path.h"
10 #include "llvm/System/Program.h"
11 using namespace llvm;
12
13 int main(int argc, const char **argv) {
14 sys::Path Program = sys::Program::FindProgramByName(argv[1]);
15 return !sys::Program::ExecuteAndWait(Program, argv + 1);
16 }