comparison src/content.c @ 49:5ecb646acf97 noffle

[svn] Article numbering bug fixes
author bears
date Sat, 06 May 2000 17:56:50 +0100
parents 32ba1198c6fa
children 125d79c9e586
comparison
equal deleted inserted replaced
48:21d3102dbc37 49:5ecb646acf97
1 /* 1 /*
2 content.c 2 content.c
3 3
4 $Id: content.c 51 2000-05-05 23:49:38Z uh1763 $ 4 $Id: content.c 55 2000-05-06 16:56:50Z bears $
5 */ 5 */
6 6
7 #if HAVE_CONFIG_H 7 #if HAVE_CONFIG_H
8 #include <config.h> 8 #include <config.h>
9 #endif 9 #endif
171 Bool anythingWritten; 171 Bool anythingWritten;
172 int i; 172 int i;
173 FILE *f; 173 FILE *f;
174 const Over *ov; 174 const Over *ov;
175 175
176
177 /* Move the first article no. to the first active article */
178 while ( ! Cont_validNumb( cont.first ) && cont.first <= cont.last )
179 ++cont.first;
180
181 /* Save the overview */ 176 /* Save the overview */
182 if ( ! ( f = fopen( cont.file, "w" ) ) ) 177 if ( ! ( f = fopen( cont.file, "w" ) ) )
183 { 178 {
184 Log_err( "Could not open %s for writing", cont.file ); 179 Log_err( "Could not open %s for writing", cont.file );
185 return; 180 return;
186 } 181 }
187 Log_dbg( "Writing %s (%lu)", cont.file, cont.size ); 182 Log_dbg( "Writing %s (%lu)", cont.file, cont.size );
188 anythingWritten = FALSE; 183 anythingWritten = FALSE;
184 cont.first = -1;
189 for ( i = 0; i < cont.size; ++i ) 185 for ( i = 0; i < cont.size; ++i )
190 { 186 {
191 if ( ( ov = cont.elem[ i ] ) ) 187 if ( ( ov = cont.elem[ i ] ) )
192 { 188 {
193 if ( ! Pseudo_isGeneralInfo( Ov_msgId( ov ) ) ) 189 if ( ! Pseudo_isGeneralInfo( Ov_msgId( ov ) ) )
196 { 192 {
197 Log_err( "Writing of overview line failed" ); 193 Log_err( "Writing of overview line failed" );
198 break; 194 break;
199 } 195 }
200 else 196 else
197 {
201 anythingWritten = TRUE; 198 anythingWritten = TRUE;
199 if ( cont.first < 0 )
200 cont.first = cont.vecFirst + i;
201 }
202 } 202 }
203 } 203 }
204 } 204 }
205 fclose( f ); 205 fclose( f );
206 206
227 Cont_first( void ) { return cont.first; } 227 Cont_first( void ) { return cont.first; }
228 228
229 int 229 int
230 Cont_last( void ) { return cont.last; } 230 Cont_last( void ) { return cont.last; }
231 231
232 int
233 Cont_find( const char *msgId )
234 {
235 int i;
236 const Over *ov;
237
238 for ( i = 0; i < cont.size; i++ )
239 {
240 if ( ( ov = cont.elem[ i ] )
241 && strcmp( Ov_msgId( ov ), msgId ) == 0 )
242 return i + cont.vecFirst;
243 }
244
245 return -1;
246 }
247
232 const char * 248 const char *
233 Cont_grp( void ) { return cont.name; } 249 Cont_grp( void ) { return cont.name; }
234 250
235 Bool 251 Bool
236 Cont_nextGrp( Str result ) 252 Cont_nextGrp( Str result )