chkdef.cmd 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /****************************************************************************
  2. * Copyright (c) 1998,2006 Free Software Foundation, Inc. *
  3. * *
  4. * Permission is hereby granted, free of charge, to any person obtaining a *
  5. * copy of this software and associated documentation files (the *
  6. * "Software"), to deal in the Software without restriction, including *
  7. * without limitation the rights to use, copy, modify, merge, publish, *
  8. * distribute, distribute with modifications, sublicense, and/or sell *
  9. * copies of the Software, and to permit persons to whom the Software is *
  10. * furnished to do so, subject to the following conditions: *
  11. * *
  12. * The above copyright notice and this permission notice shall be included *
  13. * in all copies or substantial portions of the Software. *
  14. * *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  16. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  18. * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  19. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  20. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  21. * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  22. * *
  23. * Except as contained in this notice, the name(s) of the above copyright *
  24. * holders shall not be used in advertising or otherwise to promote the *
  25. * sale, use or other dealings in this Software without prior written *
  26. * authorization. *
  27. ****************************************************************************/
  28. /*
  29. * $Id: chkdef.cmd,v 1.3 2006/04/22 23:14:50 tom Exp $
  30. *
  31. * Author: Juan Jose Garcia Ripoll <worm@arrakis.es>.
  32. * Webpage: http://www.arrakis.es/~worm/
  33. *
  34. * chkdef.cmd - checks that a .def file has no conflicts and is properly
  35. * formatted.
  36. *
  37. * returns nonzero if two symbols have the same code or a line has a wrong
  38. * format.
  39. *
  40. * returns 0 otherwise
  41. *
  42. * the standard output shows conflicts.
  43. */
  44. parse arg def_file
  45. def_file = translate(def_file,'\','/')
  46. call CleanQueue
  47. /*
  48. * `cmp' is zero when the file is valid
  49. * `codes' associates a name to a code
  50. * `names' associates a code to a name
  51. */
  52. cmp = 0
  53. codes. = 0
  54. names. = ''
  55. /*
  56. * This sed expression cleans empty lines, comments and special .DEF
  57. * commands, such as LIBRARY..., EXPORTS..., etc
  58. */
  59. tidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
  60. /*
  61. * First we find all public symbols from the original DLL. All this
  62. * information is pushed into a REXX private list with the RXQUEUE
  63. * utility program.
  64. */
  65. '@echo off'
  66. 'type' def_file '| sed' tidy_up '| sort | rxqueue'
  67. do while queued() > 0
  68. /*
  69. * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)
  70. */
  71. parse pull '"' new_name '"' '@'new_code rest
  72. select
  73. when (new_code = '') | (new_name = '') then
  74. /* The input was not properly formatted */
  75. do
  76. say 'Error: symbol "'new_name'" has no export code or is empty'
  77. cmp = 1
  78. end
  79. when codes.new_name \= 0 then
  80. /* This symbol was already defined */
  81. if codes.new_name \= new_code then
  82. do
  83. cmp = 2
  84. say 'Symbol "'new_name'" multiply defined'
  85. end
  86. when names.new_code \= '' then
  87. /* This code was already assigned to a symbol */
  88. if names.new_code \= new_name then
  89. do
  90. cmp = 3
  91. say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code
  92. end
  93. otherwise
  94. do
  95. codes.new_name = new_code
  96. names.new_code = new_name
  97. end
  98. end /* select */
  99. end
  100. exit cmp
  101. CleanQueue: procedure
  102. do while queued() > 0
  103. parse pull foo
  104. end
  105. return