4 Copyright (C) 1994-2007 Frans Slothouber, Jacco van Weert, Petteri Kettunen,
5 Bernd Koesling, Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner,
6 Sasha Vasko, Kai Hofmann, Thierry Pierron, Friedrich Haase, and Gergely Budai.
8 This file is part of ROBODoc
10 ROBODoc is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 * This module contains functions that deal with items. The
29 * documentation consists of headers, and headers contains one of
30 * more items. Each item has a name and a body. All possible items
31 * are listed in configuration.items. A uses can specify that
32 * certain items are not to be added to the documentation. These
33 * items are listed in configuration.ignore_items.
49 #include "roboconfig.h"
52 /****v* Items/item_name_buffer
54 * Stores the name of the last item that was found.
58 #define MAX_ITEM_NAME_LENGTH 1024
59 char item_name_buffer[MAX_ITEM_NAME_LENGTH];
63 /* TODO Documentation */
64 char *RB_Get_Item_Name(
67 return item_name_buffer;
70 /****f* Items/RB_Create_Item
75 struct RB_Item *RB_Create_Item(
76 enum ItemType arg_item_type )
78 struct RB_Item *item = malloc( sizeof( struct RB_Item ) );
83 item->type = arg_item_type;
84 item->begin_index = 0;
92 /****f* Items/RB_Get_Item_Type [3.0b]
94 * return the item_type represented by the given string.
96 * int RB_Get_Item_Type( char *cmp_name )
98 * char *cmp_name -- item_name to evaluate
100 * int -- the right item_type or NO_ITEM
104 int RB_Get_Item_Type(
107 unsigned int item_type;
109 assert( configuration.items.number );
110 for ( item_type = 0; item_type < configuration.items.number; ++item_type )
112 char *item = configuration.items.names[item_type];
114 /* Skip preformat mark */
117 if ( !strcmp( item, cmp_name ) )
119 return ( item_type );
125 /*** RB_Get_Item_Type ***/
129 /****f* Items/RB_Is_ItemName
131 * Is there an itemname in the line. Ignores leading spaces and
134 * line -- line to be searched.
136 * The kind of item that was found or NO_ITEM if no item could be found.
137 * The name of the item will be stored in item_name_buffer.
139 * We used to check for misspelled items names by testing if
140 * the item name buffer consists of only upper case characters.
141 * However checking for a misspelled item name this way results in
142 * many false positives. For instance many warnings are given for
143 * FORTRAN code as all the keywords are in uppercase. We need to
144 * find a better method for this.
148 enum ItemType RB_Is_ItemName(
151 char *cur_char = line;
154 cur_char = RB_Skip_Whitespace( cur_char );
155 if ( RB_Has_Remark_Marker( cur_char ) )
157 cur_char = RB_Skip_Remark_Marker( cur_char );
158 cur_char = RB_Skip_Whitespace( cur_char );
159 /* It there anything left? */
160 if ( strlen( cur_char ) )
162 enum ItemType item_type = NO_ITEM;
165 strcpy( item_name_buffer, cur_char );
166 /* remove any trailing spaces */
167 for ( i = strlen( item_name_buffer ) - 1;
168 i >= 0 && utf8_isspace( item_name_buffer[i] ); --i )
170 item_name_buffer[i] = '\0';
172 /* No check and see if this is an item name */
173 if ( strlen( item_name_buffer ) )
175 item_type = RB_Get_Item_Type( item_name_buffer );
176 #if 0 /* Until we find a better method */
177 if ( item_type == NO_ITEM )
179 /* Check if it is a misspelled item name */
180 item_type = POSSIBLE_ITEM;
181 for ( i = 0; i < strlen( item_name_buffer ); ++i )
183 if ( !( utf8_isupper( item_name_buffer[i] ) ||
184 utf8_isspace( item_name_buffer[i] ) ) )
209 /* TODO Documentation */
215 for ( i = 0; i < configuration.ignore_items.number; ++i )
217 if ( !strcmp( configuration.ignore_items.names[i], name ) )
226 /****f* HeaderTypes/Works_Like_SourceItem
228 * Tells wether this item works similar to the
229 * source item, that is weather it copies it's
230 * content verbatim to the output document.
233 int Works_Like_SourceItem(
234 enum ItemType item_type )
237 * item_type -- Type of item (also the index to the item name)
239 * TRUE -- Item works like a SOURCE item
240 * FALSE -- Item does NOT work like a SOURCE item
246 // Check if it is a SOURCE item
247 if ( item_type == SOURCECODE_ITEM )
252 // Lookup if it works like a SOURCE item
253 for ( i = 0; i < configuration.source_items.number; ++i )
256 ( configuration.source_items.names[i],
257 configuration.items.names[item_type] ) )
263 // Neither SOURCE item, nor works like it
269 /****f* HeaderTypes/Is_Preformatted_Item
271 * Tells wether this item should be automatically preformatted in the
275 int Is_Preformatted_Item(
276 enum ItemType item_type )
279 * item_type -- Type of item (also the index to the item name)
281 * TRUE -- Item should be automatically preformatted
282 * FALSE -- Item should NOT be automatically preformatted
288 // Lookup if item should be preformatted
289 for ( i = 0; i < configuration.preformatted_items.number; ++i )
292 ( configuration.preformatted_items.names[i],
293 configuration.items.names[item_type] ) )
295 // Item name match, it sould be preformatted
300 // Do not automatically preformat item
306 /****f* HeaderTypes/Is_Format_Item
308 * Tells wether this item should be formatted by the browser
312 enum ItemType item_type )
315 * item_type -- Type of item (also the index to the item name)
317 * TRUE -- Item should be formatted by the browser
318 * FALSE -- Item should be left alone
324 // Lookup if item should be formatted by the browser
325 for ( i = 0; i < configuration.format_items.number; ++i )
328 ( configuration.format_items.names[i],
329 configuration.items.names[item_type] ) )
331 // Item name match, it sould be formatted by the browser