chkdef.cmd revision 166125
1214503Srpaulo/**************************************************************************** 2214503Srpaulo * Copyright (c) 1998,2006 Free Software Foundation, Inc. * 3214503Srpaulo * * 4214503Srpaulo * Permission is hereby granted, free of charge, to any person obtaining a * 5214503Srpaulo * copy of this software and associated documentation files (the * 6214503Srpaulo * "Software"), to deal in the Software without restriction, including * 7214503Srpaulo * without limitation the rights to use, copy, modify, merge, publish, * 8214503Srpaulo * distribute, distribute with modifications, sublicense, and/or sell * 9214503Srpaulo * copies of the Software, and to permit persons to whom the Software is * 10214503Srpaulo * furnished to do so, subject to the following conditions: * 11214503Srpaulo * * 12214503Srpaulo * The above copyright notice and this permission notice shall be included * 13214503Srpaulo * in all copies or substantial portions of the Software. * 14214503Srpaulo * * 15214503Srpaulo * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16214503Srpaulo * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17214503Srpaulo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18214503Srpaulo * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19214503Srpaulo * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20214503Srpaulo * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21214503Srpaulo * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22214503Srpaulo * * 23214503Srpaulo * Except as contained in this notice, the name(s) of the above copyright * 24214503Srpaulo * holders shall not be used in advertising or otherwise to promote the * 25214503Srpaulo * sale, use or other dealings in this Software without prior written * 26214503Srpaulo * authorization. * 27214503Srpaulo ****************************************************************************/ 28214503Srpaulo 29214503Srpaulo/* 30214503Srpaulo * $Id: chkdef.cmd,v 1.3 2006/04/22 23:14:50 tom Exp $ 31214503Srpaulo * 32214503Srpaulo * Author: Juan Jose Garcia Ripoll <worm@arrakis.es>. 33214503Srpaulo * Webpage: http://www.arrakis.es/~worm/ 34214503Srpaulo * 35214503Srpaulo * chkdef.cmd - checks that a .def file has no conflicts and is properly 36214503Srpaulo * formatted. 37214503Srpaulo * 38214503Srpaulo * returns nonzero if two symbols have the same code or a line has a wrong 39214503Srpaulo * format. 40214503Srpaulo * 41214503Srpaulo * returns 0 otherwise 42214503Srpaulo * 43214503Srpaulo * the standard output shows conflicts. 44214503Srpaulo */ 45214503Srpauloparse arg def_file 46214503Srpaulo 47214503Srpaulodef_file = translate(def_file,'\','/') 48214503Srpaulo 49214503Srpaulocall CleanQueue 50214503Srpaulo 51214503Srpaulo/* 52214503Srpaulo * `cmp' is zero when the file is valid 53214503Srpaulo * `codes' associates a name to a code 54214503Srpaulo * `names' associates a code to a name 55214503Srpaulo */ 56214503Srpaulocmp = 0 57214503Srpaulocodes. = 0 58214503Srpaulonames. = '' 59214503Srpaulo 60214503Srpaulo/* 61214503Srpaulo * This sed expression cleans empty lines, comments and special .DEF 62214503Srpaulo * commands, such as LIBRARY..., EXPORTS..., etc 63214503Srpaulo */ 64214503Srpaulotidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"' 65214503Srpaulo 66214503Srpaulo/* 67214503Srpaulo * First we find all public symbols from the original DLL. All this 68214503Srpaulo * information is pushed into a REXX private list with the RXQUEUE 69214503Srpaulo * utility program. 70214503Srpaulo */ 71214503Srpaulo'@echo off' 72214503Srpaulo'type' def_file '| sed' tidy_up '| sort | rxqueue' 73214503Srpaulo 74214503Srpaulodo while queued() > 0 75214503Srpaulo /* 76214503Srpaulo * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE) 77214503Srpaulo */ 78214503Srpaulo parse pull '"' new_name '"' '@'new_code rest 79214503Srpaulo select 80214503Srpaulo when (new_code = '') | (new_name = '') then 81214503Srpaulo /* The input was not properly formatted */ 82214503Srpaulo do 83214503Srpaulo say 'Error: symbol "'new_name'" has no export code or is empty' 84214503Srpaulo cmp = 1 85214503Srpaulo end 86214503Srpaulo when codes.new_name \= 0 then 87214503Srpaulo /* This symbol was already defined */ 88214503Srpaulo if codes.new_name \= new_code then 89214503Srpaulo do 90 cmp = 2 91 say 'Symbol "'new_name'" multiply defined' 92 end 93 when names.new_code \= '' then 94 /* This code was already assigned to a symbol */ 95 if names.new_code \= new_name then 96 do 97 cmp = 3 98 say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code 99 end 100 otherwise 101 do 102 codes.new_name = new_code 103 names.new_code = new_name 104 end 105 end /* select */ 106end 107 108exit cmp 109 110CleanQueue: procedure 111 do while queued() > 0 112 parse pull foo 113 end 114return 115