Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 57d5e6a

Browse files
author
Domenico
committedMar 7, 2020
Now 29/30
1 parent 4134c23 commit 57d5e6a

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed
 

‎main.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int main(){
145145
entName1[MAX_STRING_SIZE],
146146
entName2[MAX_STRING_SIZE],
147147
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
149149

150150
while(getCommand(command, entName1, entName2, relName) != 1) {
151151
executeCommand(command, entName1, entName2, relName);
@@ -183,7 +183,7 @@ int getCommand(char *command, char *ent1, char *ent2, char *rel) {
183183
int i = 0;
184184

185185
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);
187187
command[6] = '\0';
188188

189189
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) {
198198

199199

200200
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
203203
i = 1;
204204
ent1[0] = '"';
205205
do {
206-
ent1[i] = (char)getchar_unlocked();
206+
ent1[i] = (char)getc_unlocked(stdin);
207207
i++;
208208
} while(ent1[i-1] != '"');
209209
ent1[i-1] = '"';
210210
ent1[i] = ' ';
211211
ent1[i+1] = '\0';
212212

213213
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);
216216
i = 1;
217217
ent2[0] = '"';
218218
do {
219-
ent2[i] = (char)getchar_unlocked();
219+
ent2[i] = (char)getc_unlocked(stdin);
220220
i++;
221221
} while(ent2[i-1] != '"');
222222
ent2[i-1] = '"';
223223
ent2[i] = ' ';
224224
ent2[i+1] = '\0';
225225

226-
getchar_unlocked();
227-
getchar_unlocked();
226+
getc_unlocked(stdin);
227+
getc_unlocked(stdin);
228228
i = 1;
229229
rel[0] = '"';
230230
do {
231-
rel[i] = (char)getchar_unlocked();
231+
rel[i] = (char)getc_unlocked(stdin);
232232
i++;
233233
} while(rel[i-1] != '"');
234234
rel[i-1] = '"';
@@ -237,7 +237,7 @@ int getCommand(char *command, char *ent1, char *ent2, char *rel) {
237237
}
238238
}
239239

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
241241
return 0;
242242
}
243243
/*
@@ -309,8 +309,8 @@ void deleteEntity(char* entName){
309309
if (strcmp(temp->name, entName) == 0) { //element exists
310310
if(temp->version % 2 == 0) {
311311
temp->version++;
312+
refreshFlags(temp->relations);
312313
}
313-
refreshFlags(temp->relations);
314314
return;
315315
}
316316
temp = temp->next;
@@ -384,8 +384,8 @@ void printReport() {
384384
int count = 0;
385385
count = printRelations(relRoot);
386386
if (count == 0)
387-
fputs("none", stdout);
388-
fputs("\n", stdout);
387+
fputs_unlocked("none", stdout);
388+
fputs_unlocked("\n", stdout);
389389
}
390390

391391
int printRelations(t_relationTree *node) {
@@ -636,8 +636,8 @@ t_entityTree *delTree(t_entityTree *node) {
636636
return NULL;
637637
node->leftChild = delTree(node->leftChild);
638638
node->rightChild = delTree(node->rightChild);
639-
free(node);
640-
return NULL;
639+
free(node);
640+
return NULL;
641641
}
642642

643643

@@ -700,7 +700,7 @@ void ent_printTree (t_entityTree *node) {
700700
if (node == NULL)
701701
return;
702702
ent_printTree(node->leftChild);
703-
fputs(node->entity->name, stdout);
703+
fputs_unlocked(node->entity->name, stdout);
704704
ent_printTree(node->rightChild);
705705
}
706706

@@ -878,7 +878,7 @@ int printSingleReport(t_relation *relation) {
878878
return 0;
879879
if (relation->maxSenders < 0)
880880
return 1;
881-
fputs(relation->name, stdout);
881+
fputs_unlocked(relation->name, stdout);
882882
ent_printTree(relation->recipients);
883883
printf("%d; ", relation->maxSenders);
884884
return 1;

0 commit comments

Comments
 (0)
This repository has been archived.