Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Gnome/gdk/broadway/   (Gnome Linux Desktop Version 4.23.2©)  Datei vom 30.5.2026 mit Größe 1 kB image not shown  

Quelle  gen-c-array.py

  Sprache: Python
 

#!/usr/bin/env python3

import os
import argparse
import sys
import filecmp

def replace_if_changed(new, old):
  '''
  Compare contents and only replace if changed to avoid triggering a rebuild.
  '''
  try:
    changed = not filecmp.cmp(new, old, shallow=False)
  except FileNotFoundError:
    changed = True
  if changed:
    os.replace(new, old)
  else:
    os.remove(new)

parser = argparse.ArgumentParser()
parser.add_argument('--array-name', help='The name of the array variable')
parser.add_argument('--output', metavar='STRING', help='Output filename',
                    default=None)
parser.add_argument('input', metavar='FILE', help='The input file',
                    type=argparse.FileType('r'))

args = parser.parse_args()

if args.output is None:
    output = sys.stdout
else:
    output = args.output + '~'

with open(output, 'w'as f:
    f.write('static const char {}[] = {{\n'.format(args.array_name))
    for line in args.input:
        for ch in line:
            f.write('  0x{:02x},\n'.format(ord(ch)))
    f.write('};')

if args.output is not None:
    replace_if_changed(output, args.output)

Messung V0.5 in Prozent
C=98 H=95 G=96

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-07-02) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.