Skip to content
Snippets Groups Projects
Commit 0b8764b1 authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

File: read author

parent 359a0c18
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ long_line_behaviour=1
long_line_column=72
[files]
current_page=12
current_page=19
FILE_NAME_0=309;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2FREADME;0;8
FILE_NAME_1=47;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2F.gitignore;0;8
FILE_NAME_2=1770;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fconfigure.ac;0;8
......@@ -41,14 +41,14 @@ FILE_NAME_8=4638;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fpr
FILE_NAME_9=881;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Flog.h;0;8
FILE_NAME_10=17855;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Fgrammar.c;0;8
FILE_NAME_11=6839;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Fgrammar.h;0;8
FILE_NAME_12=9357;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Ffile.c;0;8
FILE_NAME_12=5417;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Ffile.c;0;8
FILE_NAME_13=1457;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Ffile.h;0;8
FILE_NAME_14=1282;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Fword.c;0;8
FILE_NAME_15=908;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Fsrc%2Flib%2Fword.h;0;8
FILE_NAME_16=919;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Ftests%2FMakefile.am;0;8
FILE_NAME_17=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Ftests%2Fno_test.sh;0;8
FILE_NAME_18=51550;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Ftests%2Ftest_grammar.c;0;8
FILE_NAME_19=16783;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Ftests%2Ftest_file.c;0;8
FILE_NAME_19=17158;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Ftests%2Ftest_file.c;0;8
FILE_NAME_20=1731;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDocuments%2Fprojects%2Fprgm%2Flanguage%2FGSAT%2Ftests%2Ftest_word.c;0;8
[prjorg]
......
......@@ -243,6 +243,11 @@ bool
File_read_start (struct GR_File * file,
/*@null@*/ /*@out@*/ struct GR_Status * status);
static inline
bool
File_read_author (struct GR_File * file, GR_Grammar * grammar,
/*@null@*/ /*@out@*/ struct GR_Status * status);
static inline
/*@null@*/
/*@only@*/
......@@ -265,7 +270,8 @@ File_read (struct GR_File * file,
|| (!File_read_filetype (file, status))
|| (!File_read_fileversion (file, status))
|| (!File_read_name (file, grammar, status))
|| (!File_read_start (file, status)))
|| (!File_read_start (file, status))
|| (!File_read_author (file, grammar, status)))
{
GR_Grammar_free (grammar);
File_close (file, status);
......@@ -513,3 +519,26 @@ File_read_start (struct GR_File * file,
return TRUE;
}
static inline
bool
File_read_author (struct GR_File * file, GR_Grammar * grammar,
/*@null@*/ /*@out@*/ struct GR_Status * status)
{
if (NULL == file->file)
{
set_status (status, E_STATE, 2, "file not opened");
return FALSE;
}
/* read to RS */
if (!read_to (file, RS, status)) return FALSE;
/* overwrite RS with NUL */
file->buffer[file->index-1] = '\0';
/* clear buffer */
file->index = 0;
return GR_Grammar_set_author (grammar, file->buffer, status);
}
......@@ -681,6 +681,8 @@ START_TEST(test_file_read_no_status)
ck_assert_str_eq ("Deutsch_Kernsatz-jonathan",
GR_Grammar_raw_get_name (grammar));
ck_assert_int_eq (0, file->start_index);
ck_assert_str_eq ("Jonathan Schöbel",
GR_Grammar_raw_get_author (grammar));
/* cleanup */
GR_File_free (file);
......@@ -709,6 +711,8 @@ START_TEST(test_file_read_with_status)
ck_assert_str_eq ("Deutsch_Kernsatz-jonathan",
GR_Grammar_raw_get_name (grammar));
ck_assert_int_eq (0, file->start_index);
ck_assert_str_eq ("Jonathan Schöbel",
GR_Grammar_raw_get_author (grammar));
/* cleanup */
GR_File_free (file);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment