home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW noweb 2.7 / src / c / errors.nw < prev    next >
LaTeX Document  |  1995-05-30  |  2.4 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: LaTeX Document (document/latex).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert NWiper Show (other/nWiperShow) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 43 6f 70 79 72 69 | 67 68 74 20 31 39 39 31 |% Copyri|ght 1991|
|00000010| 20 62 79 20 4e 6f 72 6d | 61 6e 20 52 61 6d 73 65 | by Norm|an Ramse|
|00000020| 79 2e 20 20 41 6c 6c 20 | 72 69 67 68 74 73 20 72 |y. All |rights r|
|00000030| 65 73 65 72 76 65 64 2e | 0d 25 20 53 65 65 20 66 |eserved.|.% See f|
|00000040| 69 6c 65 20 43 4f 50 59 | 52 49 47 48 54 20 66 6f |ile COPY|RIGHT fo|
|00000050| 72 20 6d 6f 72 65 20 69 | 6e 66 6f 72 6d 61 74 69 |r more i|nformati|
|00000060| 6f 6e 2e 0d 5c 73 75 62 | 73 65 63 74 69 6f 6e 7b |on..\sub|section{|
|00000070| 45 72 72 6f 72 20 6d 65 | 73 73 61 67 65 73 7d 0d |Error me|ssages}.|
|00000080| 48 65 72 65 20 69 73 20 | 61 20 62 69 67 20 73 65 |Here is |a big se|
|00000090| 74 20 6f 66 20 66 75 6e | 63 74 69 6f 6e 73 20 74 |t of fun|ctions t|
|000000a0| 68 61 74 20 6f 74 68 65 | 72 20 70 6c 61 63 65 73 |hat othe|r places|
|000000b0| 20 63 61 6e 20 63 61 6c | 6c 20 74 6f 20 69 73 73 | can cal|l to iss|
|000000c0| 75 65 0d 65 72 72 6f 72 | 20 6d 65 73 73 61 67 65 |ue.error| message|
|000000d0| 73 2e 0d 0d 49 74 20 6d | 69 67 68 74 20 62 65 20 |s...It m|ight be |
|000000e0| 77 6f 72 74 68 20 69 6d | 70 6c 65 6d 65 6e 74 69 |worth im|plementi|
|000000f0| 6e 67 20 74 68 65 73 65 | 20 61 73 20 6d 61 63 72 |ng these| as macr|
|00000100| 6f 73 20 73 6f 20 74 68 | 65 79 20 63 6f 75 6c 64 |os so th|ey could|
|00000110| 20 69 6e 64 69 63 61 74 | 65 0d 74 68 65 20 66 69 | indicat|e.the fi|
|00000120| 6c 65 20 6e 61 6d 65 20 | 61 6e 64 20 6c 69 6e 65 |le name |and line|
|00000130| 20 6e 75 6d 62 65 72 20 | 69 6e 20 74 68 65 20 73 | number |in the s|
|00000140| 6f 75 72 63 65 20 6f 66 | 20 77 68 65 72 65 20 74 |ource of| where t|
|00000150| 68 65 79 20 77 65 72 65 | 20 63 61 6c 6c 65 64 2e |hey were| called.|
|00000160| 0d 0d 5b 5b 65 72 72 6f | 72 6c 65 76 65 6c 5d 5d |..[[erro|rlevel]]|
|00000170| 20 69 73 20 61 6e 20 69 | 6e 74 65 67 65 72 20 74 | is an i|nteger t|
|00000180| 68 61 74 20 73 61 79 73 | 20 68 6f 77 20 62 61 64 |hat says| how bad|
|00000190| 20 74 68 65 20 77 6f 72 | 73 74 20 65 72 72 6f 72 | the wor|st error|
|000001a0| 20 73 6f 20 66 61 72 0d | 68 61 73 20 62 65 65 6e | so far.|has been|
|000001b0| 2e 0d 5b 5b 6e 65 77 65 | 72 72 6f 72 6c 65 76 65 |..[[newe|rrorleve|
|000001c0| 6c 5d 5d 20 77 69 6c 6c | 20 75 70 64 61 74 65 20 |l]] will| update |
|000001d0| 69 74 20 63 6f 6e 64 69 | 74 69 6f 6e 61 6c 6c 79 |it condi|tionally|
|000001e0| 2e 0d 53 6f 6d 65 20 64 | 61 79 20 77 65 20 73 68 |..Some d|ay we sh|
|000001f0| 6f 75 6c 64 20 68 69 64 | 65 20 69 74 20 61 6e 64 |ould hid|e it and|
|00000200| 20 67 69 76 65 20 74 68 | 65 20 77 6f 72 6c 64 20 | give th|e world |
|00000210| 61 20 66 75 6e 63 74 69 | 6f 6e 20 63 61 6c 6c 20 |a functi|on call |
|00000220| 74 68 61 74 0d 71 75 65 | 72 69 65 73 20 69 74 2e |that.que|ries it.|
|00000230| 0d 3c 3c 2a 3e 3e 3d 0d | 23 69 6e 63 6c 75 64 65 |.<<*>>=.|#include|
|00000240| 20 3c 73 74 64 69 6f 2e | 68 3e 0d 23 69 6e 63 6c | <stdio.|h>.#incl|
|00000250| 75 64 65 20 3c 73 74 64 | 6c 69 62 2e 68 3e 0d 23 |ude <std|lib.h>.#|
|00000260| 69 6e 63 6c 75 64 65 20 | 3c 73 74 72 69 6e 67 2e |include |<string.|
|00000270| 68 3e 0d 23 69 6e 63 6c | 75 64 65 20 3c 73 74 64 |h>.#incl|ude <std|
|00000280| 61 72 67 2e 68 3e 0d 23 | 69 6e 63 6c 75 64 65 20 |arg.h>.#|include |
|00000290| 22 65 72 72 6f 72 73 2e | 68 22 0d 0d 3c 3c 43 20 |"errors.|h"..<<C |
|000002a0| 66 75 6e 63 74 69 6f 6e | 73 3e 3e 0d 40 0d 49 20 |function|s>>.@.I |
|000002b0| 74 72 61 63 6b 20 64 65 | 67 72 65 65 73 20 6f 66 |track de|grees of|
|000002c0| 20 65 72 72 6f 72 20 61 | 73 20 74 68 65 79 20 6f | error a|s they o|
|000002d0| 63 63 75 72 2e 0d 3c 3c | 68 65 61 64 65 72 3e 3e |ccur..<<|header>>|
|000002e0| 3d 0d 65 6e 75 6d 20 65 | 72 72 6f 72 6c 65 76 65 |=.enum e|rrorleve|
|000002f0| 6c 20 7b 20 4e 6f 72 6d | 61 6c 3d 30 2c 20 57 61 |l { Norm|al=0, Wa|
|00000300| 72 6e 69 6e 67 2c 20 45 | 72 72 6f 72 2c 20 46 61 |rning, E|rror, Fa|
|00000310| 74 61 6c 2c 20 49 6d 70 | 6f 73 73 69 62 6c 65 20 |tal, Imp|ossible |
|00000320| 7d 3b 0d 65 78 74 65 72 | 6e 20 65 6e 75 6d 20 65 |};.exter|n enum e|
|00000330| 72 72 6f 72 6c 65 76 65 | 6c 20 65 72 72 6f 72 6c |rrorleve|l errorl|
|00000340| 65 76 65 6c 3b 0d 40 20 | 25 64 65 66 20 65 72 72 |evel;.@ |%def err|
|00000350| 6f 72 6c 65 76 65 6c 0d | 3c 3c 43 20 66 75 6e 63 |orlevel.|<<C func|
|00000360| 74 69 6f 6e 73 3e 3e 3d | 0d 65 6e 75 6d 20 65 72 |tions>>=|.enum er|
|00000370| 72 6f 72 6c 65 76 65 6c | 20 65 72 72 6f 72 6c 65 |rorlevel| errorle|
|00000380| 76 65 6c 20 3d 20 4e 6f | 72 6d 61 6c 3b 0d 40 0d |vel = No|rmal;.@.|
|00000390| 54 68 65 20 72 65 73 74 | 20 69 73 20 6a 75 73 74 |The rest| is just|
|000003a0| 20 76 61 72 79 69 6e 67 | 20 66 6c 61 76 6f 72 73 | varying| flavors|
|000003b0| 20 6f 66 20 65 72 72 6f | 72 20 6d 65 73 73 61 67 | of erro|r messag|
|000003c0| 65 73 2e 0d 3c 3c 68 65 | 61 64 65 72 3e 3e 3d 0d |es..<<he|ader>>=.|
|000003d0| 76 6f 69 64 20 65 72 72 | 6f 72 6d 73 67 28 65 6e |void err|ormsg(en|
|000003e0| 75 6d 20 65 72 72 6f 72 | 6c 65 76 65 6c 20 6c 65 |um error|level le|
|000003f0| 76 65 6c 2c 20 63 68 61 | 72 20 2a 73 2c 20 2e 2e |vel, cha|r *s, ..|
|00000400| 2e 29 3b 0d 23 64 65 66 | 69 6e 65 20 6f 76 65 72 |.);.#def|ine over|
|00000410| 66 6c 6f 77 28 53 29 20 | 65 72 72 6f 72 6d 73 67 |flow(S) |errormsg|
|00000420| 28 46 61 74 61 6c 2c 22 | 43 61 70 61 63 69 74 79 |(Fatal,"|Capacity|
|00000430| 20 65 78 63 65 65 64 65 | 64 3a 20 25 73 22 2c 20 | exceede|d: %s", |
|00000440| 53 29 0d 23 64 65 66 69 | 6e 65 20 69 6d 70 6f 73 |S).#defi|ne impos|
|00000450| 73 69 62 6c 65 28 53 29 | 20 65 72 72 6f 72 6d 73 |sible(S)| errorms|
|00000460| 67 28 49 6d 70 6f 73 73 | 69 62 6c 65 2c 20 22 54 |g(Imposs|ible, "T|
|00000470| 68 69 73 20 63 61 6e 27 | 74 20 68 61 70 70 65 6e |his can'|t happen|
|00000480| 3a 20 25 73 22 2c 20 53 | 29 0d 23 64 65 66 69 6e |: %s", S|).#defin|
|00000490| 65 20 63 68 65 63 6b 70 | 74 72 28 50 29 20 64 6f |e checkp|tr(P) do|
|000004a0| 20 7b 20 69 66 20 28 21 | 28 50 29 29 20 6f 76 65 | { if (!|(P)) ove|
|000004b0| 72 66 6c 6f 77 28 22 6d | 65 6d 6f 72 79 22 29 3b |rflow("m|emory");|
|000004c0| 20 7d 20 77 68 69 6c 65 | 20 28 30 29 0d 40 20 25 | } while| (0).@ %|
|000004d0| 64 65 66 20 65 72 72 6f | 72 6d 73 67 20 6f 76 65 |def erro|rmsg ove|
|000004e0| 72 66 6c 6f 77 20 69 6d | 70 6f 73 73 69 62 6c 65 |rflow im|possible|
|000004f0| 20 63 68 65 63 6b 70 74 | 72 0d 3c 3c 43 20 66 75 | checkpt|r.<<C fu|
|00000500| 6e 63 74 69 6f 6e 73 3e | 3e 3d 0d 76 6f 69 64 20 |nctions>|>=.void |
|00000510| 65 72 72 6f 72 6d 73 67 | 28 65 6e 75 6d 20 65 72 |errormsg|(enum er|
|00000520| 72 6f 72 6c 65 76 65 6c | 20 6c 65 76 65 6c 2c 20 |rorlevel| level, |
|00000530| 63 68 61 72 20 2a 73 2c | 2e 2e 2e 29 20 7b 20 20 |char *s,|...) { |
|00000540| 20 20 20 0d 20 20 20 20 | 76 61 5f 6c 69 73 74 20 | . |va_list |
|00000550| 61 72 67 73 3b 20 20 20 | 20 20 20 20 20 20 20 20 |args; | |
|00000560| 20 20 20 20 20 20 20 20 | 20 20 20 20 2f 2a 20 73 | | /* s|
|00000570| 65 65 20 4b 26 52 2c 20 | 70 61 67 65 20 31 37 34 |ee K&R, |page 174|
|00000580| 20 2a 2f 0d 20 20 20 20 | 76 61 5f 73 74 61 72 74 | */. |va_start|
|00000590| 28 61 72 67 73 2c 73 29 | 3b 0d 20 20 20 20 3c 3c |(args,s)|;. <<|
|000005a0| 73 65 74 20 5b 5b 65 72 | 72 6f 72 6c 65 76 65 6c |set [[er|rorlevel|
|000005b0| 5d 5d 20 61 6e 64 20 70 | 72 69 6e 74 20 5b 5b 73 |]] and p|rint [[s|
|000005c0| 5d 5d 20 77 69 74 68 20 | 5b 5b 61 72 67 73 5d 5d |]] with |[[args]]|
|000005d0| 3e 3e 0d 20 20 20 20 76 | 61 5f 65 6e 64 28 61 72 |>>. v|a_end(ar|
|000005e0| 67 73 29 3b 0d 20 20 20 | 20 69 66 20 28 6c 65 76 |gs);. | if (lev|
|000005f0| 65 6c 20 3e 3d 20 46 61 | 74 61 6c 29 0d 20 20 20 |el >= Fa|tal). |
|00000600| 20 20 20 20 20 65 78 69 | 74 28 6c 65 76 65 6c 29 | exi|t(level)|
|00000610| 3b 0d 7d 0d 40 20 25 64 | 65 66 20 65 72 72 6f 72 |;.}.@ %d|ef error|
|00000620| 6d 73 67 0d 3c 3c 68 65 | 61 64 65 72 3e 3e 3d 0d |msg.<<he|ader>>=.|
|00000630| 76 6f 69 64 20 65 72 72 | 6f 72 61 74 28 63 68 61 |void err|orat(cha|
|00000640| 72 20 2a 66 69 6c 65 6e | 61 6d 65 2c 20 69 6e 74 |r *filen|ame, int|
|00000650| 20 6c 69 6e 65 6e 6f 2c | 20 65 6e 75 6d 20 65 72 | lineno,| enum er|
|00000660| 72 6f 72 6c 65 76 65 6c | 20 6c 65 76 65 6c 2c 20 |rorlevel| level, |
|00000670| 63 68 61 72 20 2a 73 2c | 20 2e 2e 2e 29 3b 0d 3c |char *s,| ...);.<|
|00000680| 3c 43 20 66 75 6e 63 74 | 69 6f 6e 73 3e 3e 3d 0d |<C funct|ions>>=.|
|00000690| 76 6f 69 64 20 65 72 72 | 6f 72 61 74 28 63 68 61 |void err|orat(cha|
|000006a0| 72 20 2a 66 69 6c 65 6e | 61 6d 65 2c 20 69 6e 74 |r *filen|ame, int|
|000006b0| 20 6c 69 6e 65 6e 6f 2c | 20 65 6e 75 6d 20 65 72 | lineno,| enum er|
|000006c0| 72 6f 72 6c 65 76 65 6c | 20 6c 65 76 65 6c 2c 20 |rorlevel| level, |
|000006d0| 63 68 61 72 20 2a 73 2c | 20 2e 2e 2e 29 20 7b 20 |char *s,| ...) { |
|000006e0| 20 20 20 20 0d 20 20 20 | 20 76 61 5f 6c 69 73 74 | . | va_list|
|000006f0| 20 61 72 67 73 3b 20 20 | 20 20 20 20 20 20 20 20 | args; | |
|00000700| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 2f 2a 20 | | /* |
|00000710| 73 65 65 20 4b 26 52 2c | 20 70 61 67 65 20 31 37 |see K&R,| page 17|
|00000720| 34 20 2a 2f 0d 20 20 20 | 20 76 61 5f 73 74 61 72 |4 */. | va_star|
|00000730| 74 28 61 72 67 73 2c 73 | 29 3b 0d 20 20 20 20 66 |t(args,s|);. f|
|00000740| 70 72 69 6e 74 66 28 73 | 74 64 65 72 72 2c 20 22 |printf(s|tderr, "|
|00000750| 5c 22 25 73 5c 22 2c 20 | 6c 69 6e 65 20 25 64 3a |\"%s\", |line %d:|
|00000760| 20 22 2c 20 66 69 6c 65 | 6e 61 6d 65 2c 20 6c 69 | ", file|name, li|
|00000770| 6e 65 6e 6f 29 3b 0d 20 | 20 20 20 3c 3c 73 65 74 |neno);. | <<set|
|00000780| 20 5b 5b 65 72 72 6f 72 | 6c 65 76 65 6c 5d 5d 20 | [[error|level]] |
|00000790| 61 6e 64 20 70 72 69 6e | 74 20 5b 5b 73 5d 5d 20 |and prin|t [[s]] |
|000007a0| 77 69 74 68 20 5b 5b 61 | 72 67 73 5d 5d 3e 3e 0d |with [[a|rgs]]>>.|
|000007b0| 20 20 20 20 76 61 5f 65 | 6e 64 28 61 72 67 73 29 | va_e|nd(args)|
|000007c0| 3b 0d 20 20 20 20 69 66 | 20 28 6c 65 76 65 6c 20 |;. if| (level |
|000007d0| 3e 3d 20 46 61 74 61 6c | 29 0d 20 20 20 20 20 20 |>= Fatal|). |
|000007e0| 20 20 65 78 69 74 28 6c | 65 76 65 6c 29 3b 0d 7d | exit(l|evel);.}|
|000007f0| 0d 40 20 25 64 65 66 20 | 65 72 72 6f 72 61 74 0d |.@ %def |errorat.|
|00000800| 3c 3c 73 65 74 20 5b 5b | 65 72 72 6f 72 6c 65 76 |<<set [[|errorlev|
|00000810| 65 6c 5d 5d 20 61 6e 64 | 20 70 72 69 6e 74 20 5b |el]] and| print [|
|00000820| 5b 73 5d 5d 20 77 69 74 | 68 20 5b 5b 61 72 67 73 |[s]] wit|h [[args|
|00000830| 5d 5d 3e 3e 3d 0d 69 66 | 20 28 6c 65 76 65 6c 20 |]]>>=.if| (level |
|00000840| 3e 20 65 72 72 6f 72 6c | 65 76 65 6c 29 0d 20 20 |> errorl|evel). |
|00000850| 20 20 65 72 72 6f 72 6c | 65 76 65 6c 20 3d 20 6c | errorl|evel = l|
|00000860| 65 76 65 6c 3b 0d 76 66 | 70 72 69 6e 74 66 28 73 |evel;.vf|printf(s|
|00000870| 74 64 65 72 72 2c 20 73 | 2c 20 61 72 67 73 29 3b |tderr, s|, args);|
|00000880| 0d 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|00000890| 22 5c 6e 22 29 3b 0d 40 | 0d 53 6f 6d 65 20 6f 6c |"\n");.@|.Some ol|
|000008a0| 64 65 72 20 6d 61 63 68 | 69 6e 65 73 20 64 6f 6e |der mach|ines don|
|000008b0| 27 74 20 64 6f 20 5b 5b | 76 66 70 72 69 6e 74 66 |'t do [[|vfprintf|
|000008c0| 5d 5d 3b 20 68 65 72 65 | 27 73 20 61 6e 20 69 6d |]]; here|'s an im|
|000008d0| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 3a 0d 3c 3c |plementa|tion:.<<|
|000008e0| 63 72 6f 63 6b 20 66 6f | 72 20 6e 6f 6e 2d 41 4e |crock fo|r non-AN|
|000008f0| 53 49 20 6d 61 63 68 69 | 6e 65 73 3e 3e 3d 0d 65 |SI machi|nes>>=.e|
|00000900| 78 74 65 72 6e 20 69 6e | 74 20 5f 64 6f 70 72 6e |xtern in|t _doprn|
|00000910| 74 28 63 6f 6e 73 74 20 | 63 68 61 72 20 2a 66 6f |t(const |char *fo|
|00000920| 72 6d 61 74 2c 20 76 61 | 5f 6c 69 73 74 20 61 72 |rmat, va|_list ar|
|00000930| 67 73 2c 20 46 49 4c 45 | 20 2a 73 74 72 65 61 6d |gs, FILE| *stream|
|00000940| 29 3b 0d 0d 69 6e 74 20 | 76 66 70 72 69 6e 74 66 |);..int |vfprintf|
|00000950| 28 46 49 4c 45 20 2a 73 | 74 72 65 61 6d 2c 20 63 |(FILE *s|tream, c|
|00000960| 6f 6e 73 74 20 63 68 61 | 72 20 2a 66 6f 72 6d 61 |onst cha|r *forma|
|00000970| 74 2c 20 76 61 5f 6c 69 | 73 74 20 61 72 67 29 20 |t, va_li|st arg) |
|00000980| 7b 20 0d 20 20 20 20 72 | 65 74 75 72 6e 20 5f 64 |{ . r|eturn _d|
|00000990| 6f 70 72 6e 74 28 66 6f | 72 6d 61 74 2c 61 72 67 |oprnt(fo|rmat,arg|
|000009a0| 2c 73 74 72 65 61 6d 29 | 3b 0d 7d 0d 0d 0d |,stream)|;.}... |
+--------+-------------------------+-------------------------+--------+--------+