From owner-svn-src-all@freebsd.org Fri Feb 16 13:57:48 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 076E3F15F56 for ; Fri, 16 Feb 2018 13:57:48 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 65C637ABB3 for ; Fri, 16 Feb 2018 13:57:47 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-lf0-f51.google.com with SMTP id f137so4159707lfe.4 for ; Fri, 16 Feb 2018 05:57:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=DpPMD+zBTMsR+GwmYL6zKJRDfoK4MAPCuhZofwJ0ZXk=; b=sRTTQzjXPiMLfb5kXDo84OJRHPvGzohCCKQzDHQ+DGdCYt+oM1k6as2kspeLX08EYo GhdaNiFRRqZJV+wSHb5fbh5k3JQKQY1HxpUvOv94TbF7U4sWj/r2TvBtcWOtOLW9RYX5 vbGgwlwehhxMN//rjJ5fB8UPxkoVMvow5yjSVqTZR3b7KlO8C0mwo7J7Yi+ZoIgAaxNN ZATVJsw8K9E7CkM8AQPXEC1Y8p+KaW9qFRwdpzGlG7bmMz23FqbXCtpXGllBlM8c0A4P PbbfuBtNlanbgb+NqrAhJ2v0D1bw4G127NrU2Hwez64wROaA86tQgeqA5njLYpKtfaV8 esIQ== X-Gm-Message-State: APf1xPD1xY/PFYwLFR+UGa8llfidNt8DcgDLRzuQ4DtqhKe5OXjGJELm dyPA10EccV/gXoq2zYYla+lu3dONU+E= X-Google-Smtp-Source: AH8x22476Jbw1IlH0DcfYc5gBv2NHexN2pRBt2YjWXWmidhcNAz0EQiDMbdDTbIrGXUrACrQ12YO9Q== X-Received: by 10.46.91.206 with SMTP id m75mr3767776lje.59.1518789459783; Fri, 16 Feb 2018 05:57:39 -0800 (PST) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com. [209.85.215.54]) by smtp.gmail.com with ESMTPSA id t69sm1409797ljb.36.2018.02.16.05.57.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 05:57:39 -0800 (PST) Received: by mail-lf0-f54.google.com with SMTP id h78so4161892lfg.6 for ; Fri, 16 Feb 2018 05:57:39 -0800 (PST) X-Received: by 10.46.64.203 with SMTP id r72mt5013129lje.38.1518789458740; Fri, 16 Feb 2018 05:57:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.106.8 with HTTP; Fri, 16 Feb 2018 05:57:18 -0800 (PST) In-Reply-To: <201802160312.w1G3CO3r085739@repo.freebsd.org> References: <201802160312.w1G3CO3r085739@repo.freebsd.org> From: Kyle Evans Date: Fri, 16 Feb 2018 07:57:18 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r329349 - head/stand/lua Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Feb 2018 13:57:48 -0000 On Thu, Feb 15, 2018 at 9:12 PM, Kyle Evans wrote: > Author: kevans > Date: Fri Feb 16 03:12:24 2018 > New Revision: 329349 > URL: https://svnweb.freebsd.org/changeset/base/329349 > > Log: > stand/lua: Reduce magic numbers > > Enter/backspace values are hardcoded in both the menu and password scripts. > Separate these out to core for reuse between the two. > > Modified: > head/stand/lua/core.lua > head/stand/lua/menu.lua > head/stand/lua/password.lua > > Modified: head/stand/lua/core.lua > ============================================================================== > --- head/stand/lua/core.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/core.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -28,6 +28,10 @@ > > local core = {}; > > +-- Commonly appearing constants > +core.KEY_ENTER = 13 > +core.KEY_BACKSPACE = 127 > + > function core.setVerbose(b) > if (b == nil) then > b = not core.verbose; > > Modified: head/stand/lua/menu.lua > ============================================================================== > --- head/stand/lua/menu.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/menu.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -273,9 +273,9 @@ function menu.run(m) > local key = io.getchar(); > > -- Special key behaviors > - if (key == 127) and (m ~= menu.welcome) then > + if (key == core.KEY_BACKSPACE) and (m ~= menu.welcome) then > break > - elseif (key == 13) then > + elseif (key == core.KEY_ENTER) then > core.boot(); > -- Should not return > end > @@ -357,7 +357,7 @@ function menu.autoboot() > screen.defcursor(); > if io.ischar() then > local ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > else > -- prevent autoboot when escaping to interpreter > > Modified: head/stand/lua/password.lua > ============================================================================== > --- head/stand/lua/password.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/password.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -37,11 +37,11 @@ function password.read() > > repeat > ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > end > > - if ch == 8 then > + if ch == core.KEY_BACKSPACE then It's worth noting that this changes the comparison from 'ch == 8' to 'ch == 127'. The password prompt was non-functional on my test systems until this change, because I can never type my password right the first time. =) Pointed out by: cem@