This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: running mks toolkit and cygwin on same machine

Why not just roll-your own 'rev'?

Included is a trivial '' that will handle any size argument list that
cygwin is able to pass it. It should include <algorithm> to support gcc 3.1,
but for some reason it couldn't process templates when I included that.

Compile with
g++ -o rev.exe


// Licenced under the GNU General Public Licence version 2.0 or greater, a
copy of which can be obtained
// from
// Copyright (c) 2002 Robert Collins.

#include <vector>
#include <iostream>
#include <algo.h>

template <class T> struct print : public unary_function<T, void>
  print(ostream& out) : os(out) {}
  void operator() (T x) { os << x << ' '; }
  ostream& os;

int main (int argc, char **argv)
  vector <char *> args;
  // assumes argv[0] is this process. This can be incorrect with some uses
  // of exec, but should be fine for shell scripts
  for (int n=1; n < argc; ++n)
    args.push_back (argv[n]);
  for_each (args.rbegin() ,args.rend (), print<char *>(cout));

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]