~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

« back to all changes in this revision

Viewing changes to application.cpp

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-07-09 10:44:01 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130709104401-5q66ozz5j5af0dak
Tags: 0.5+dfsg-3
* Upload to unstable.
* modify remove_failing_tests_on_32bits.patch to replace command of
  0009RenderStairCase test with an empty one instead of deleting it.
* remove lintian override about spelling error

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#include <stdlib.h>
5
5
#include <stdio.h>
6
6
#include <string>
 
7
#include <list>
7
8
 
8
9
#include "field.h"  //REMOVE THIS INCLUDE
9
10
 
 
11
using namespace std;
 
12
 
10
13
#define APPLICATIONNAME "gfan"
11
14
 
12
15
Application *Application::applicationList;
23
26
      l--;
24
27
    }
25
28
  while(p[l]!=0 && p[l]!='/');
26
 
  
 
29
 
27
30
  return p+l+1;
28
31
}
29
32
 
30
33
static char* tail(char *p)
31
34
{
32
 
  char *n=APPLICATIONNAME;
 
35
  const char *n=APPLICATIONNAME;
33
36
 
34
 
  char *m=n;
 
37
  const char *m=n;
35
38
  assert(p);
36
39
  while(*m)
37
40
    {
131
134
      return ret;
132
135
    }
133
136
 
134
 
  
 
137
 
135
138
  return 0;
136
139
}
137
140
 
151
154
  {
152
155
    return "Internal application for generating the LaTeX documentation.\n";
153
156
  }
154
 
  char *name()
 
157
  const char *name()
155
158
  {
156
159
    return "documentation";
157
160
  }
184
187
  {
185
188
    return "Internal application for installing symboilic links.\n";
186
189
  }
187
 
  char *name()
 
190
  const char *name()
188
191
  {
189
192
    return "installlinks";
190
193
  }
441
444
 
442
445
 
443
446
bool Application::includeInDefaultInstallation()
444
 
 
447
{
445
448
  return true;
446
449
}
447
450
 
451
454
  for(int t=1+argumentsToSkip;t<argc;t++)
452
455
    {
453
456
      int numberOfMatchesFound=0;
454
 
      
 
457
 
455
458
      for(Option *i=optionList;i;i=i->next)
456
459
        {
457
460
          if(i->matches(argv[t]))numberOfMatchesFound++;
464
467
          fprintf(stderr,"USE --help AS A SINGLE OPTION TO VIEW THE HELP TEXT.\n");
465
468
          return false;
466
469
        }
467
 
      
 
470
 
468
471
      for(Option *i=optionList;i;i=i->next)
469
472
        if(i->matches(argv[t]))
470
473
          {
507
510
  fprintf(stderr,"%s",helpText());
508
511
 
509
512
  Application *p=applicationList;
510
 
  
 
513
 
511
514
  FILE *f=stderr;
512
515
  Option *l=optionList;
513
516
  if(l)
514
517
    {
515
518
      fprintf(f,"Options:\n");
516
 
      
 
519
 
517
520
      while(l)
518
521
        {
519
522
          if(!l->isHidden())fprintf(f,"%s:\n %s\n",l->documentationMatchString().c_str(),l->documentationDescription().c_str());
535
538
  return 0;
536
539
}
537
540
 
538
 
void Application::makeSymbolicLinks(char *name, bool all, const char *path)
 
541
void Application::makeSymbolicLinks(const char *name, bool all, const char *path)
539
542
{
540
543
  Application *p=applicationList;
541
544
  while(p)
545
548
          {
546
549
            char c[1024];
547
550
            sprintf(c,"ln -s %s%s %s%s%s\n",path,name,path,name,p->name());
548
 
            fprintf(stderr,c);
 
551
            fprintf(stderr,"%s",c);
549
552
            system(c);
550
553
          }
551
554
      p=p->next;
597
600
      else
598
601
        fprintf(f,"%c",s[0]);
599
602
      s++;
600
 
    }  
 
603
    }
 
604
}
 
605
 
 
606
static bool compare_appname(Application *a, Application *b)
 
607
{
 
608
  return string(a->name())<string(b->name());
 
609
}
 
610
 
 
611
std::list<Application*> Application::getSortedApplicationList()
 
612
{
 
613
  Application *p=applicationList;
 
614
  list<Application*> alist2;
 
615
  while(p)
 
616
    {
 
617
      alist2.push_back(p);
 
618
      p=p->next;
 
619
    }
 
620
 
 
621
  alist2.sort(compare_appname);
 
622
  return alist2;
601
623
}
602
624
 
603
625
void Application::produceLatexDocumentation(bool all)
604
626
{
605
627
  FILE *f=stdout;
606
 
  Application *p=applicationList;
607
 
 
608
 
  while(p)
 
628
 
 
629
  std::list<Application*> alist2=getSortedApplicationList();
 
630
 
 
631
  //  while(p)
 
632
  for(list<Application*>::const_iterator i=alist2.begin();i!=alist2.end();i++)
609
633
    {
 
634
      Application *p=*i;
610
635
      if(all || p->includeInDefaultInstallation())
611
636
        {
612
637
          fprintf(f,"{\\subsection{%s",APPLICATIONNAME);
615
640
 
616
641
          fprintf(f,"\\label{applist:%s}\n",p->name());
617
642
          quoteLatexPrint(f,p->helpText());
618
 
          
 
643
 
619
644
          Option *l=p->optionList;
620
645
 
621
646
          bool containsNonHidden=false;
625
650
            {
626
651
              fprintf(f,"\\newline\n");
627
652
              fprintf(f,"{\\bf Options:}\n");
628
 
              
 
653
 
629
654
              fprintf(f,"\\begin{description}\n");
630
655
              while(l)
631
656
                {
640
665
                }
641
666
              fprintf(f,"\\end{description}\n");
642
667
            }
 
668
          fprintf(f,"\n\n");
643
669
        }
644
 
      p=p->next;
 
670
      //      p=p->next;
645
671
    }
646
672
}
647
673