~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/scripts/mk_html_example.pl

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
#########################################################################
 
4
 
5
#  The Contents of this file are made available subject to the terms of
 
6
#  the Sun Industry Standards Source License Version 1.2
 
7
 
8
#  Sun Microsystems Inc., March, 2001
 
9
 
10
 
11
#  Sun Industry Standards Source License Version 1.2
 
12
#  =================================================
 
13
#  The contents of this file are subject to the Sun Industry Standards
 
14
#  Source License Version 1.2 (the "License"); You may not use this file
 
15
#  except in compliance with the License. You may obtain a copy of the
 
16
#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
17
 
18
#  Software provided under this License is provided on an "AS IS" basis,
 
19
#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
20
#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
21
#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
22
#  See the License for the specific provisions governing your rights and
 
23
#  obligations concerning the Software.
 
24
 
25
#   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
26
 
27
#   Copyright: 2001 by Sun Microsystems, Inc.
 
28
 
29
#   All Rights Reserved.
 
30
 
31
#########################################################################
 
32
#
 
33
# This script creates a preformated, line numbered HTML segment from a
 
34
# source file.
 
35
#
 
36
# Syntax:
 
37
#    mk_html_example.pl sourcefile
 
38
#
 
39
# Example:
 
40
#    mk_html_example.pl libs/japi/howto/howto1.c
 
41
#
 
42
#########################################################################
 
43
 
 
44
if (@ARGV != 1) {
 
45
   usage ();
 
46
   exit;
 
47
}
 
48
 
 
49
$file = $ARGV[0];
 
50
$count = -1;
 
51
 
 
52
open (FILE, "<$file");
 
53
 
 
54
while (<FILE>) {
 
55
   if ($count < 0) {
 
56
      if (m#/\*___INFO__MARK_END__\*/#) {
 
57
         $count = 0;
 
58
      }
 
59
 
 
60
      next;
 
61
   }
 
62
 
 
63
   $count++;
 
64
}
 
65
 
 
66
close FILE;
 
67
 
 
68
if ($count < 0) {
 
69
   print "This file does not contain an /*___INFO__MARK_END__*/ line.\n";
 
70
   exit;
 
71
}
 
72
 
 
73
$num_figs = 0;
 
74
 
 
75
do {
 
76
   $num_figs++;
 
77
   $count /= 10;
 
78
} while (int ($count) > 0);
 
79
 
 
80
$count = -1;
 
81
 
 
82
open (FILE, "<$file");
 
83
 
 
84
while (<FILE>) {
 
85
   if ($count < 0) {
 
86
      if (m#/\*___INFO__MARK_END__\*/#) {
 
87
         $count = 0;
 
88
      }
 
89
 
 
90
      next;
 
91
   }
 
92
   elsif ($count == 0) {
 
93
      print "<PRE>";
 
94
   }
 
95
   else {
 
96
      print "\n";
 
97
   }
 
98
 
 
99
   chomp;
 
100
 
 
101
   printCount ($count);
 
102
   print;
 
103
   $count++;
 
104
}
 
105
 
 
106
close FILE;
 
107
 
 
108
if ($count >= 0) {
 
109
   print "</PRE>\n";
 
110
}
 
111
 
 
112
sub usage {
 
113
   print "mk_html_example.pl sourcefile\n";
 
114
}
 
115
 
 
116
sub printCount {
 
117
   $diff = $num_figs - length ($count + 1);
 
118
 
 
119
   for (;$diff > 0; $diff--) {
 
120
      print "0";
 
121
   }
 
122
 
 
123
   print $count + 1;
 
124
   print ": ";
 
125
}
 
 
b'\\ No newline at end of file'