view anagram/agcore/rproc.h @ 7:57b2cc9b87f7

Use memcpy instead of strncpy when we know the length anyway. Modern gcc seems to think it knows how to detect misuse of strncpy, but it's wrong (in fact: very, very wrong) and the path of least resistance is to not try to fight with it.
author David A. Holland
date Mon, 30 May 2022 23:47:52 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * rproc.h
 */

#ifndef RPROC_H
#define RPROC_H

#include "register.h"

struct CSegment {
  unsigned char *begin;
  unsigned char *end;
  int line;

  // this is in pgg24.syn and moving it would make an ugly mess
  CSegment();

  int length() { return end - begin; }
  int operator < (const CSegment &s) const { return begin < s.begin; }
};

struct ProcedureDescriptor;

class Procedure : public ObjectRegister<ProcedureDescriptor> {
public:
  Procedure() {}
  Procedure(const int x);
  //Procedure(const Procedure &t) : ObjectRegister<ProcedureDescriptor>(t) {}
  Procedure(const CSegment &t);
  static const int first;
  static void reset();
  int operator < (const Procedure p) const;
};

struct ProcedureDescriptor {
  int cast;
  //int n_params;
  //unsigned cast_index;
  //int auto_proc;
  int alias;
  int line, col;
  int form_number;
  CSegment cSegment;
  //int *args;
  int macro_flag : 1;
  int value_flag : 1;

  ProcedureDescriptor();
  ProcedureDescriptor(const CSegment &);
  int operator < (const ProcedureDescriptor &d) const {
    return cSegment.begin < d.cSegment.begin;
  }
};


#endif /* RPROC_H */