coan 4.2.4
|
00001 /*************************************************************************** 00002 * Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org * 00003 * All rights reserved. * 00004 * * 00005 * Contributed originally by Mike Kinghan, imk@strudl.org * 00006 * * 00007 * Redistribution and use in source and binary forms, with or without * 00008 * modification, are permitted provided that the following conditions * 00009 * are met: * 00010 * * 00011 * Redistributions of source code must retain the above copyright * 00012 * notice, this list of conditions and the following disclaimer. * 00013 * * 00014 * Redistributions in binary form must reproduce the above copyright * 00015 * notice, this list of conditions and the following disclaimer in the * 00016 * documentation and/or other materials provided with the distribution. * 00017 * * 00018 * Neither the name of Symbian Software Ltd. nor the names of its * 00019 * contributors may be used to endorse or promote products derived from * 00020 * this software without specific prior written permission. * 00021 * * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * 00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,* 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 00033 * DAMAGE. * 00034 * * 00035 **************************************************************************/ 00036 #include "includes_tally.h" 00037 #include "args.h" 00038 #include "report.h" 00039 00047 NO_PRIVATE_STATE(includes_tally); 00052 IMPLEMENT(includes_tally,USER_INITABLE); 00053 00054 DEFINE_USER_INIT(includes_tally)(STATE_T(includes_tally) * st_state) 00055 { 00056 st_state->includes_tab = 00057 ptr_set_new((comparator_t)hash_include_compare, 00058 (dtor_t)hash_include_dispose, 00059 (cloner_t)hash_include_copy); 00060 00061 } 00062 00063 DEFINE_USER_FINIS(includes_tally)(STATE_T(includes_tally) * st_state) 00064 { 00065 ptr_set_dispose(st_state->includes_tab); 00066 } 00069 /* Helpers */ 00070 00074 00075 /* Helpers */ 00076 00087 static hash_include_h 00088 hash_include_lookup(char const *arg, size_t arglen) 00089 { 00090 hash_include_h inc_arg = 00091 ptr_set_search(GET_PUBLIC(includes_tally,includes_tab), 00092 arg,arglen); 00093 return inc_arg; 00094 } 00095 00099 static void 00100 hash_include_add(hash_include_h inc_arg) 00101 { 00102 ptr_set_insert(GET_PUBLIC(includes_tally,includes_tab),inc_arg); 00103 } 00104 00107 /* API *********************************************************************/ 00108 00109 void 00110 hash_include_tally( char const *arg, 00111 size_t arglen, 00112 canonical_string_const_h sym_def) 00113 { 00114 hash_include_h inc_arg = hash_include_lookup(arg,arglen); 00115 if (!inc_arg) { 00116 inc_arg = hash_include_new(arg,arglen); 00117 if (sym_def) { 00118 hash_include_define(inc_arg,sym_def); 00119 } 00120 hash_include_add(inc_arg); 00121 report_include(inc_arg); 00122 } else { 00123 canonical_string_const_h old_def = hash_include_definition(inc_arg); 00124 if (sym_def) { 00125 if (!old_def || !canonical_string_equal(sym_def,old_def)) { 00126 hash_include_define(inc_arg,sym_def); 00127 } 00128 } else if (old_def) { 00129 hash_include_undefine(inc_arg,arg + arglen,NULL); 00130 } 00131 if (!GET_PUBLIC(args,list_only_once)) { 00132 report_include(inc_arg); 00133 } 00134 } 00135 } 00136 00137 /* EOF*/