00001 /*****************************************************************************\ 00002 * * 00003 * Name : to_lower * 00004 * Author : Chris Koeritz * 00005 * * 00006 * Purpose: * 00007 * * 00008 * Lowers the case used in file names? contents? * 00009 * * 00010 ******************************************************************************* 00011 * Copyright (c) 1993-$now By Author. This program is free software; you can * 00012 * redistribute it and/or modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; either version 2 of * 00014 * the License or (at your option) any later version. This is online at: * 00015 * http://www.fsf.org/copyleft/gpl.html * 00016 * Please send any updates to: fred@gruntose.com * 00017 \*****************************************************************************/ 00018 00019 #include <basis/istring.h> 00020 #include <loggers/console_logger.h> 00021 #include <data_struct/static_memory_gremlin.h> 00022 00023 #include <stdio.h> 00024 00025 HOOPLE_STARTUP_CODE; 00026 00027 #define COMMENT_CHARACTER '-' 00028 00029 console_logger out; 00030 00031 enum states { 00032 TO_LOWER, 00033 PASS_THROUGH_QUOTE, 00034 // PASS_THROUGH_APOSTROPHE, 00035 COMMENT 00036 }; 00037 00038 int main(int formal(argc), char *formal(argv)[]) 00039 { 00040 out.eol(log_base::NO_ENDING); 00041 states state = TO_LOWER; 00042 char last_char = '\0'; 00043 while (!feof(stdin)) { 00044 char current = getc(stdin); 00045 if (feof(stdin)) break; 00046 if (current == '"') { 00047 switch (state) { 00048 case COMMENT: break; 00049 case PASS_THROUGH_QUOTE: state = TO_LOWER; break; 00050 // case PASS_THROUGH_APOSTROPHE: break; 00051 case TO_LOWER: state = PASS_THROUGH_QUOTE; break; 00052 } 00053 // } else if (current == '\'') { 00054 // switch (state) { 00055 // case COMMENT: break; 00056 // case PASS_THROUGH_QUOTE: break; 00057 // case PASS_THROUGH_APOSTROPHE: state = TO_LOWER; break; 00058 // case TO_LOWER: state = PASS_THROUGH_APOSTROPHE; break; 00059 // } 00060 } else if (current == COMMENT_CHARACTER) { 00061 if ( (state != COMMENT) && (state != PASS_THROUGH_QUOTE) 00062 && (last_char == COMMENT_CHARACTER) ) 00063 state = COMMENT; 00064 } else if ( (current == '\n') && (state == COMMENT) ) state = TO_LOWER; 00065 istring one_char(current, 1); 00066 switch (state) { 00067 case COMMENT: break; 00068 case TO_LOWER: one_char.to_lower(); break; 00069 case PASS_THROUGH_QUOTE: break; 00070 // case PASS_THROUGH_APOSTROPHE: break; 00071 } 00072 out.log(one_char); 00073 last_char = one_char[0]; 00074 } 00075 return 0; 00076 } 00077 00078 #ifdef __BUILD_STATIC_APPLICATION__ 00079 // static dependencies found by buildor_gen_deps.sh: 00080 #include <basis/array.cpp> 00081 #include <basis/byte_array.cpp> 00082 #include <basis/callstack_tracker.cpp> 00083 #include <basis/chaos.cpp> 00084 #include <basis/convert_utf.cpp> 00085 #include <basis/definitions.cpp> 00086 #include <basis/earth_time.cpp> 00087 #include <basis/guards.cpp> 00088 #include <basis/istring.cpp> 00089 #include <basis/log_base.cpp> 00090 #include <basis/memory_checker.cpp> 00091 #include <basis/mutex.cpp> 00092 #include <basis/object_base.cpp> 00093 #include <basis/outcome.cpp> 00094 #include <basis/packable.cpp> 00095 #include <basis/portable.cpp> 00096 #include <basis/sequence.cpp> 00097 #include <basis/set.cpp> 00098 #include <basis/utility.cpp> 00099 #include <basis/version_record.cpp> 00100 #include <data_struct/amorph.cpp> 00101 #include <data_struct/bit_vector.cpp> 00102 #include <data_struct/byte_hasher.cpp> 00103 #include <data_struct/configurator.cpp> 00104 #include <data_struct/hash_table.cpp> 00105 #include <data_struct/pointer_hash.cpp> 00106 #include <data_struct/stack.cpp> 00107 #include <data_struct/static_memory_gremlin.cpp> 00108 #include <data_struct/string_hash.cpp> 00109 #include <data_struct/string_hasher.cpp> 00110 #include <data_struct/string_table.cpp> 00111 #include <data_struct/symbol_table.cpp> 00112 #include <data_struct/table_configurator.cpp> 00113 #include <loggers/console_logger.cpp> 00114 #include <loggers/file_logger.cpp> 00115 #include <loggers/locked_logger.cpp> 00116 #include <loggers/null_logger.cpp> 00117 #include <loggers/program_wide_logger.cpp> 00118 #include <opsystem/byte_filer.cpp> 00119 #include <opsystem/command_line.cpp> 00120 #include <opsystem/critical_events.cpp> 00121 #include <opsystem/directory.cpp> 00122 #include <opsystem/filename.cpp> 00123 #include <opsystem/ini_config.cpp> 00124 #include <opsystem/ini_parser.cpp> 00125 #include <opsystem/path_configuration.cpp> 00126 #include <opsystem/rendezvous.cpp> 00127 #include <textual/byte_format.cpp> 00128 #include <textual/parser_bits.cpp> 00129 #include <textual/string_manipulation.cpp> 00130 #include <textual/tokenizer.cpp> 00131 #endif // __BUILD_STATIC_APPLICATION__ 00132
1.5.1