Changeset 2f48445 in rtems-tools


Ignore:
Timestamp:
Sep 5, 2014, 8:10:46 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
7ccb670
Parents:
40fd7a0
Message:

Return the requested label.

This completes this code to a basic working level. It usable for the
RTEMS pc files but not as a full pkgconfig replacement. The python
version in the RSB is more complete.

Location:
linkers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • linkers/pkgconfig.cpp

    r40fd7a0 r2f48445  
    11/*
    2  * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
     2 * Copyright (c) 2011-2014, Chris Johns <chrisj@rtems.org>
    33 *
    44 * Permission to use, copy, modify, and/or distribute this software for any
    55 * purpose with or without fee is hereby granted, provided that the above
    66 * copyright notice and this permission notice appear in all copies.
    7  * 
     7 *
    88 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     
    1919#include <string>
    2020
     21#include <rld.h>
    2122#include <pkgconfig.h>
    2223
    2324namespace pkgconfig
    2425{
    25   void tolower (std::string& str)
     26  package::package (const std::string& name)
    2627  {
    27     std::transform (str.begin (), str.end (), str.begin (), ::tolower);
     28    load (name);
    2829  }
    2930
    30   package::package (void)
     31  package::package ()
    3132  {
    3233  }
     
    4243
    4344      in.getline (buffer, sizeof (buffer));
    44      
     45
    4546      std::string line (buffer);
    4647      size_t      hash;
     
    8485        if (d != std::string::npos)
    8586        {
    86           std::string lhs = line.substr (0, d);
     87          std::string lhs = rld::tolower (line.substr (0, d));
    8788          std::string rhs = line.substr (d + 1);
    88 
    89           tolower (lhs);
    90 
    9189          if (def)
    9290            defines[lhs] = rhs;
     
    105103    result.erase ();
    106104
    107     std::string ll = label;
    108     tolower (ll);
    109    
     105    std::string     ll = rld::tolower (label);
    110106    table::iterator ti = fields.find (ll);
    111    
     107
    112108    if (ti == fields.end ())
    113109      return false;
     
    123119    bool expanded = true;
    124120    while (expanded)
    125     {       
     121    {
    126122      /*
    127123       * Need to perform a regular expression search for '\$\{[^\}]+\}'. This
     
    129125       * and finish with a '}'.
    130126       */
     127      expanded = false;
    131128      size_t p = 0;
    132129      while (p < s.length ())
     
    141138          if (me != std::string::npos)
    142139          {
    143             std::string ml = s.substr (ms, me);
    144            
     140            std::string     ml = rld::tolower(s.substr (ms + 2, me - ms - 2));
     141            table::iterator di = defines.find (ml);
     142            if (di != defines.end ())
     143            {
     144              s = rld::find_replace (s, s.substr (ms, me - ms + 1),  di->second);
     145              expanded = true;
     146            }
     147            p = me + 1;
     148          }
     149          else
     150          {
     151            p = ms + 2;
    145152          }
    146153        }
     
    151158      }
    152159    }
    153    
     160
     161    result = s;
     162
    154163    return true;
    155164  }
  • linkers/pkgconfig.h

    r40fd7a0 r2f48445  
    3636    typedef std::map < std::string, std::string > table;
    3737
     38    /**
     39     * Constructor and load the file.
     40     */
     41    package (const std::string& name);
     42
     43    /**
     44     * Default constructor.
     45     */
    3846    package ();
    3947
     
    5866    table defines;  ///< The defines.
    5967    table fields;   ///< The fields.
    60 
    6168  };
    6269
Note: See TracChangeset for help on using the changeset viewer.