Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cpp fixes for Sun /usr/lib/cpp compatibility #12

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Commits on Sep 21, 2013

  1. [HACK] cpp: add some simple test tools

    - test.sh: run /usr/lib/cpp and ./cpp against either specified headers,
      or all (most) headers in /usr/include, and report on differences.
    
    - squash.py: coalesce the results of test.sh (expected on stdin), so
      each diff hunk is reported only once (line numbers are ignored,
      context is not)
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    5825a37 View commit details
    Browse the repository at this point in the history
  2. [HACK] cpp: make it easier to find macro sources

    This is a dubiously useful hack, but invaluable when debugging the
    preprocessor.
    
    If CPP_DEBUG_DEFINITIONS is in the environment, output to stderr at
    every macro definition its name, and the defining file and line number,
    such that the operative definition of common macros (such as __P) can be
    determined.
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    61d063c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b6857d2 View commit details
    Browse the repository at this point in the history
  4. cpp: squash spaces correctly-ish whilst pasting macros

    Sun cpp removes all leading and trailing space from a macro pasting, and
    compress whitespace in the macro body to a single space character.
    
    There is some deviation from this in the Sun implementation which we
    don't duplicate.
    
    1) The presence of comments in the macro body affect the minimization of
       runs of spaces.
    
    2) When newlines are encountered in the parameter list of a macro
       invocation, Sun cpp inserts that many newlines prior to any of the
       pasted text, and then in the pasted text pastes those newlines as
       (minimized) spaces.  Escaped new-lines are de-escaped, and otherwise
       treated similarly (in effect, the \ is removed).
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    d86b945 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    76ccafe View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ea5ba79 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d2ee643 View commit details
    Browse the repository at this point in the history
  8. cpp: only consider macro calls unterminated if they ever began

    We should only error about an unterminated macro parameter list if a
    parameter list was begun.  If we never even seen the _first_
    parenthesis, there is nothing to terminate.
    
    Previously, we would set the parenthesis level to -1 when expecting
    parameters (such that when we saw the opening paren it became the 0th
    level), but when checking for unterminated expansion we would strictly
    compare to 0, and thus flag a macro which needed parameters but lacked
    them as having an unterminated parameter list.
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    cf28293 View commit details
    Browse the repository at this point in the history
  9. cpp: if a macro with parameters is invoked without any, don't destroy…

    … state
    
    Previously, we would parse a macro foo() presuming that we would always
    see the opening parenthesis indicating the begining of the parameter
    list.  If we saw 'foo' we would consume the token _following_ 'foo'
    presuming it would be the parenthesis, and if it was not, would not
    paste it to the output.
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    b376914 View commit details
    Browse the repository at this point in the history
  10. cpp: allow vastly more #defines

    <inet/tcp.h> requires considerably more defines to preprocess than the
    4,000 we previously allowed.  Allow an (equally arbitrary) 16,000
    symbols instead.
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    017b97d View commit details
    Browse the repository at this point in the history
  11. cpp: don't handroll an incorrect strtoul(3c), use the one in libc

    The previous implementation would parse 0x7ff as 0x755 (etc).
    richlowe committed Sep 21, 2013
    Configuration menu
    Copy the full SHA
    20da04f View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    d362662 View commit details
    Browse the repository at this point in the history