@@ -145,7 +145,7 @@ int main(){
145
145
entName1 [MAX_STRING_SIZE ],
146
146
entName2 [MAX_STRING_SIZE ],
147
147
relName [MAX_STRING_SIZE ];
148
- //freopen("TestCases/3_Mixup/batch3.1.in", "r", stdin); //redirecting standard input, used for debugging in CLion
148
+ //freopen("TestCases/3_Mixup/batch3.1.in", "r", stdin); //redirecting standard input, used for debugging in CLion
149
149
150
150
while (getCommand (command , entName1 , entName2 , relName ) != 1 ) {
151
151
executeCommand (command , entName1 , entName2 , relName );
@@ -183,7 +183,7 @@ int getCommand(char *command, char *ent1, char *ent2, char *rel) {
183
183
int i = 0 ;
184
184
185
185
for (i = 0 ; i < 6 ; i ++ ) //reading the first 6 chatacters, containing the command
186
- command [i ] = (char )getchar_unlocked ( );
186
+ command [i ] = (char )getc_unlocked ( stdin );
187
187
command [6 ] = '\0' ;
188
188
189
189
if (command [0 ] == 'e' && //if it encounters the last line, it cannot compare strings with
@@ -198,37 +198,37 @@ int getCommand(char *command, char *ent1, char *ent2, char *rel) {
198
198
199
199
200
200
if (strcmp (command , "report" ) != 0 ){ //if the command is not a report, it requires at least one attribute to work
201
- getchar_unlocked ( ); //dump the space and quote before the attribute
202
- getchar_unlocked ( ); //not very elegant, but it works
201
+ getc_unlocked ( stdin ); //dump the space and quote before the attribute
202
+ getc_unlocked ( stdin ); //not very elegant, but it works
203
203
i = 1 ;
204
204
ent1 [0 ] = '"' ;
205
205
do {
206
- ent1 [i ] = (char )getchar_unlocked ( );
206
+ ent1 [i ] = (char )getc_unlocked ( stdin );
207
207
i ++ ;
208
208
} while (ent1 [i - 1 ] != '"' );
209
209
ent1 [i - 1 ] = '"' ;
210
210
ent1 [i ] = ' ' ;
211
211
ent1 [i + 1 ] = '\0' ;
212
212
213
213
if ((strcmp (command , "addrel" ) == 0 ) || (strcmp (command , "delrel" ) == 0 )) { //if the command works on relatonships, it needs all three attributes
214
- getchar_unlocked ( );
215
- getchar_unlocked ( );
214
+ getc_unlocked ( stdin );
215
+ getc_unlocked ( stdin );
216
216
i = 1 ;
217
217
ent2 [0 ] = '"' ;
218
218
do {
219
- ent2 [i ] = (char )getchar_unlocked ( );
219
+ ent2 [i ] = (char )getc_unlocked ( stdin );
220
220
i ++ ;
221
221
} while (ent2 [i - 1 ] != '"' );
222
222
ent2 [i - 1 ] = '"' ;
223
223
ent2 [i ] = ' ' ;
224
224
ent2 [i + 1 ] = '\0' ;
225
225
226
- getchar_unlocked ( );
227
- getchar_unlocked ( );
226
+ getc_unlocked ( stdin );
227
+ getc_unlocked ( stdin );
228
228
i = 1 ;
229
229
rel [0 ] = '"' ;
230
230
do {
231
- rel [i ] = (char )getchar_unlocked ( );
231
+ rel [i ] = (char )getc_unlocked ( stdin );
232
232
i ++ ;
233
233
} while (rel [i - 1 ] != '"' );
234
234
rel [i - 1 ] = '"' ;
@@ -237,7 +237,7 @@ int getCommand(char *command, char *ent1, char *ent2, char *rel) {
237
237
}
238
238
}
239
239
240
- while ((char )getchar_unlocked ( ) != '\n' ){} //dump any other character. You don't wanna remove this
240
+ while ((char )getc_unlocked ( stdin ) != '\n' ){} //dump any other character. You don't wanna remove this
241
241
return 0 ;
242
242
}
243
243
/*
@@ -309,8 +309,8 @@ void deleteEntity(char* entName){
309
309
if (strcmp (temp -> name , entName ) == 0 ) { //element exists
310
310
if (temp -> version % 2 == 0 ) {
311
311
temp -> version ++ ;
312
+ refreshFlags (temp -> relations );
312
313
}
313
- refreshFlags (temp -> relations );
314
314
return ;
315
315
}
316
316
temp = temp -> next ;
@@ -384,8 +384,8 @@ void printReport() {
384
384
int count = 0 ;
385
385
count = printRelations (relRoot );
386
386
if (count == 0 )
387
- fputs ("none" , stdout );
388
- fputs ("\n" , stdout );
387
+ fputs_unlocked ("none" , stdout );
388
+ fputs_unlocked ("\n" , stdout );
389
389
}
390
390
391
391
int printRelations (t_relationTree * node ) {
@@ -636,8 +636,8 @@ t_entityTree *delTree(t_entityTree *node) {
636
636
return NULL ;
637
637
node -> leftChild = delTree (node -> leftChild );
638
638
node -> rightChild = delTree (node -> rightChild );
639
- free (node );
640
- return NULL ;
639
+ free (node );
640
+ return NULL ;
641
641
}
642
642
643
643
@@ -700,7 +700,7 @@ void ent_printTree (t_entityTree *node) {
700
700
if (node == NULL )
701
701
return ;
702
702
ent_printTree (node -> leftChild );
703
- fputs (node -> entity -> name , stdout );
703
+ fputs_unlocked (node -> entity -> name , stdout );
704
704
ent_printTree (node -> rightChild );
705
705
}
706
706
@@ -878,7 +878,7 @@ int printSingleReport(t_relation *relation) {
878
878
return 0 ;
879
879
if (relation -> maxSenders < 0 )
880
880
return 1 ;
881
- fputs (relation -> name , stdout );
881
+ fputs_unlocked (relation -> name , stdout );
882
882
ent_printTree (relation -> recipients );
883
883
printf ("%d; " , relation -> maxSenders );
884
884
return 1 ;
0 commit comments