summaryrefslogtreecommitdiff
path: root/src/Scilab2C/Annotations/Sci2AnnotationFile.sci
blob: a704654360611919464f7d5096c2b14735695824 (plain)
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
function Sci2AnnotationFile(FileInfoDatFile,SciFileName)
// function Sci2AnnotationFile(FileInfoDatFile,SciFileName)
// --------------------------------------------------------------------------------
// This function reads the .sci input file and generates the correspondig .ann
// file.
//
// Input data:
// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
//
// Output data:
//
// Status:
// 25-Jun-2007 -- Nutricato Raffaele: Author.
// -----------------------------------------------------------------

// ---------------------
// --- Load section. ---
// ---------------------
// --- Load File Info Structure. ---
load(FileInfoDatFile,'FileInfo');

// --- Load Shared Info Structure. ---
load(FileInfo.SharedInfoDatFile,'SharedInfo');

// --- Extraction of the function name and number. ---
funname   = SharedInfo.Next(1).SCIFunName;
funnumber = SharedInfo.NextSCIFunNumber;
// -------------------------
// --- End load section. ---
// -------------------------

// --- File names initialization. ---
[tmppath,tmpname,tmpext] = fileparts(SciFileName);
AnnFileName = fullfile(FileInfo.USER2CLibAnnDirName,tmpname+'.ann');

PrintStepInfo('Generate annotations file: '+AnnFileName,...
   FileInfo.GeneralReport,'both');

// ---------------------------------------
// --- Open the .sci file (read only). ---
// ---------------------------------------
[inscifid,inscierr] = mopen(SciFileName,'r');
if (inscierr < 0)
   SCI2Cerror(['Cannot open (in read mode): '+SciFileName]);
end

// ----------------------------------------------
// --- Loop over the lines of the input file. ---
// ----------------------------------------------
line_position = 0;
while (meof(inscifid) == 0)
   check_string = stripblanks(mgetl(inscifid,1));
   line_position = line_position + 1;
   if (length(check_string) >= 1)
      if ((SCI2Cstrncmps1size(SharedInfo.Annotations.GBLVAR,check_string)) | ...
         (SCI2Cstrncmps1size(SharedInfo.Annotations.VARTYPE,check_string)) | ...
         (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNOUT,check_string)) | ...
         (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNSIZE,check_string)) | ...
         (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNTYPE,check_string)))
         PrintStringInfo('Line '+string(line_position)+' - Found Annotation:: '+' ""'+check_string+' ""',...
            FileInfo.GeneralReport,'file','y');
         PrintStringInfo(check_string,...
            AnnFileName,'file','y');
 
      end
   end
end
// --------------------------------------------------
// --- End loop over the lines of the input file. ---
// --------------------------------------------------

mclose(inscifid);
endfunction