Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  LogCommandLineHandler.cpp

  Sprache: C
 

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "LogCommandLineHandler.h"

#include "mozilla/Tokenizer.h"
#include "nsDebug.h"

namespace mozilla {

void LoggingHandleCommandLineArgs(
    int argc, char constconst* argv,
    std::function<void(nsACString const&)> const& consumer) {
  // Keeps the name of a pending env var (MOZ_LOG or MOZ_LOG_FILE) that
  // we expect to get a value for in the next iterated arg.
  // Used for the `-MOZ_LOG <modules>` form of argument.
  nsAutoCString env;

  auto const names = {"MOZ_LOG"_ns, "MOZ_LOG_FILE"_ns};

  for (int arg = 1; arg < argc; ++arg) {
    Tokenizer p(argv[arg]);

    if (!env.IsEmpty() && p.CheckChar('-')) {
      NS_WARNING(
          "Expects value after -MOZ_LOG(_FILE) argument, but another argument "
          "found");

      // We only expect values for the pending env var, start over
      p.Rollback();
      env.Truncate();
    }

    if (env.IsEmpty()) {
      if (!p.CheckChar('-')) {
        continue;
      }
      // We accept `-MOZ_LOG` as well as `--MOZ_LOG`.
      Unused << p.CheckChar('-');

      for (auto const& name : names) {
        if (!p.CheckWord(name)) {
          continue;
        }

        env.Assign(name);
        env.Append('=');
        break;
      }

      if (env.IsEmpty()) {
        // An unknonwn argument, ignore.
        continue;
      }

      // We accept `-MOZ_LOG <modules>` as well as `-MOZ_LOG=<modules>`.

      if (p.CheckEOF()) {
        // We have a lone `-MOZ_LOG` arg, the next arg is expected to be
        // the value, |env| is now prepared as `MOZ_LOG=`.
        continue;
      }

      if (!p.CheckChar('=')) {
        // There is a character after the arg name and it's not '=',
        // ignore this argument.
        NS_WARNING("-MOZ_LOG(_FILE) argument not in a proper form");

        env.Truncate();
        continue;
      }
    }

    // This can be non-empty from previous iteration or in this iteration.
    if (!env.IsEmpty()) {
      nsDependentCSubstring value;
      Unused << p.ReadUntil(Tokenizer::Token::EndOfFile(), value);
      env.Append(value);

      consumer(env);

      env.Truncate();
    }
  }
}

}  // namespace mozilla

Messung V0.5 in Prozent
C=85 H=96 G=90

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-04) ¤

*© 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik