1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
/****h* ROBODoc/Items
* FUNCTION
* This module contains functions that deal with items. The
* documentation consists of headers, and headers contains one of
* more items. Each item has a name and a body. All possible items
* are listed in configuration.item_names. A uses can specify that
* certain items are not to be added to the documentation. These
* items are listed in configuration.ignore_items.
* AUTHOR
* Frans Slothouber
*******
*/
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include "globals.h"
#include "robodoc.h"
#include "items.h"
#include "roboconfig.h"
#include "util.h"
/****v* Items/item_name_buffer
* FUNCTION
* Stores the name of the last item that was found.
* SOURCE
*/
#define MAX_ITEM_NAME_LENGTH 1024
char item_name_buffer[MAX_ITEM_NAME_LENGTH];
/*****/
/* TODO Documentation */
char* RB_Get_Item_Name( void )
{
return item_name_buffer;
}
/****f* Items/RB_Get_Item_Type [3.0b]
* FUNCTION
* return the item_type represented by the given string.
* SYNOPSIS
* int RB_Get_Item_Type( char *cmp_name )
* INPUTS
* char *cmp_name -- item_name to evaluate
* RESULT
* int -- the right item_type or NO_ITEM
* SOURCE
*/
int
RB_Get_Item_Type( char *cmp_name )
{
unsigned int item_type;
for ( item_type = 0; item_type < configuration.no_items; ++item_type )
{
if ( !strcmp( configuration.item_names[item_type], cmp_name ) )
{
return ( item_type );
}
}
return ( NO_ITEM );
}
/*** RB_Get_Item_Type ***/
/****f* Items/RB_Is_ItemName
* FUNCTION
* Is there an itemname in the line. Ignores leading spaces and
* remark markers.
* INPUTS
* line -- line to be searched.
* RESULT
* The kind of item that was found or NO_ITEM if no item could be found.
* The name of the item will be stored in item_name_buffer.
* NOTES
* We used to check for misspelled items names by testing if
* the item name buffer consists of only upper case characters.
* However checking for a misspelled item name this way results in
* many false positives. For instance many warnings are given for
* FORTRAN code as all the keywords are in uppercase. We need to
* find a better method for this.
* SOURCE
*/
enum ItemType
RB_Is_ItemName( char *line )
{
char *cur_char = line;
int i = 0;
cur_char = RB_Skip_Whitespace( cur_char );
if ( RB_Has_Remark_Marker( cur_char ) )
{
cur_char = RB_Skip_Remark_Marker( cur_char );
cur_char = RB_Skip_Whitespace( cur_char );
/* It there anything left? */
if ( strlen( cur_char ) )
{
enum ItemType item_type = NO_ITEM;
/* Copy the name */
strcpy( item_name_buffer, cur_char );
/* remove any trailing spaces */
for ( i = strlen( item_name_buffer ) - 1;
i >= 0 && isspace( item_name_buffer[i] ); --i )
{
item_name_buffer[i] = '\0';
}
/* No check and see if this is an item name */
if ( strlen( item_name_buffer ) )
{
item_type = RB_Get_Item_Type( item_name_buffer );
#if 0 /* Until we find a better method */
if ( item_type == NO_ITEM )
{
/* Check if it is a misspelled item name */
item_type = POSSIBLE_ITEM;
for ( i = 0; i < strlen( item_name_buffer ); ++i )
{
if ( !( isupper( item_name_buffer[ i ] ) ||
isspace( item_name_buffer[ i ] ) ) )
{
/* No it is not */
item_type = NO_ITEM;
break;
}
}
}
#endif
}
return item_type;
}
else
{
return NO_ITEM;
}
}
else
{
return NO_ITEM;
}
}
#if 0
int
RB_Is_ItemName( char *line )
{
char *cur_char = line;
int i = 0;
cur_char = RB_Skip_Whitespace( cur_char );
cur_char = RB_Skip_Remark_Marker( cur_char );
cur_char = RB_Skip_Whitespace( cur_char );
/* It there anything left? */
if ( strlen( cur_char ) )
{
int item_type = NO_ITEM;
/* Copy the name */
strcpy( item_name_buffer, cur_char );
/* remove any trailing spaces */
for ( i = strlen( item_name_buffer ) - 1;
i >= 0 && isspace( item_name_buffer[i] ); --i )
{
item_name_buffer[i] = '\0';
}
/* No check and see if this is an item name */
if ( strlen( item_name_buffer ) )
{
item_type = RB_Get_Item_Type( item_name_buffer );
#if 0 /* Until we find a better method */
if ( item_type == NO_ITEM )
{
/* Check if it is a misspelled item name */
item_type = POSSIBLE_ITEM;
for ( i = 0; i < strlen( item_name_buffer ); ++i )
{
if ( !( isupper( item_name_buffer[ i ] ) ||
isspace( item_name_buffer[ i ] ) ) )
{
/* No it is not */
item_type = NO_ITEM;
break;
}
}
}
#endif
}
return item_type;
}
else
{
return NO_ITEM;
}
}
#endif
/******/
/****f* Items/RB_Ignore_Last_Item
* FUNCTION
* Tell whether the last item that was found using
* RB_Is_ItemName() is in the list with items that
* are to be ignored when generating documentation.
* SYNOPSIS
* int RB_Ignore_Last_Item()
* RESUTL
* TRUE -- item is in the ignore_items list
* FALSE -- item is not in the ignore_items list
* SOURCE
*/
int
RB_Ignore_Last_Item( void )
{
unsigned int i;
for ( i = 0; i < configuration.no_ignore_items; ++i )
{
if ( !strcmp( configuration.ignore_items[i], item_name_buffer ) )
{
return TRUE;
}
}
return FALSE;
}
/******/
|